From: hooanon05@yahoo.co.jp To: iscsitarget-devel@lists.sourceforge.net Subject: parameter parsing bug? Date: Mon, 13 Jun 2005 20:25:24 +0900 Hello, all. i am afraid there is a minor bug around parsing fileio parameters. it will cause a memory leak in kernel space when the user specifies a same parameter more than once. here is a patch, but i didnt test it. if it is a bug actually, please merge this > tomof Junjiro Okajima Index: iet-0.4.10/kernel/file-io.c =================================================================== RCS file: /ext1/iscsi/repository/iet-0.4.10/kernel/file-io.c,v retrieving revision 1.3 diff -u -r1.3 file-io.c --- iet-0.4.10/kernel/file-io.c 11 Jun 2005 17:45:23 -0000 1.3 +++ iet-0.4.10/kernel/file-io.c 13 Jun 2005 11:19:37 -0000 @@ -156,7 +156,7 @@ static int parse_fileio_params(struct iet_volume *volume, char *params) { int err = 0; - char *p, *path = NULL, *scsiid = NULL; + char *p, *arg; while ((p = strsep(¶ms, ",")) != NULL) { substring_t args[MAX_OPT_ARGS]; @@ -168,19 +168,23 @@ case Opt_type: break; case Opt_scsiid: - if (!(scsiid = match_strdup(&args[0]))) { + if (!(arg = match_strdup(&args[0]))) { err = -ENOMEM; goto out; } - if ((err = set_scsiid(volume, scsiid)) < 0) + err = set_scsiid(volume, arg); + kfree(arg); + if (err < 0) goto out; break; case Opt_path: - if (!(path = match_strdup(&args[0]))) { + if (!(arg = match_strdup(&args[0]))) { err = -ENOMEM; goto out; } - if ((err = open_path(volume, path)) < 0) + err = open_path(volume, arg); + kfree(arg); + if (err < 0) return err; break; default: @@ -191,9 +195,6 @@ } out: - kfree(path); - kfree(scsiid); - return err; }