isofs: fix potential memory leak in mount option parsing
authorChengguang Xu <cgxu519@gmx.com>
Sat, 14 Apr 2018 12:16:06 +0000 (20:16 +0800)
committerJan Kara <jack@suse.cz>
Mon, 16 Apr 2018 07:47:41 +0000 (09:47 +0200)
When specifying string type mount option (e.g., iocharset)
several times in a mount, current option parsing may
cause memory leak. Hence, call kfree for previous one
in this case. Meanwhile, check memory allocation result
for it.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/isofs/inode.c

index bc258a4402f6afbc921a508db37f95002f2ff7f0..ec3fba7d492f483e14accbfd98d5b63550f2591c 100644 (file)
@@ -394,7 +394,10 @@ static int parse_options(char *options, struct iso9660_options *popt)
                        break;
 #ifdef CONFIG_JOLIET
                case Opt_iocharset:
+                       kfree(popt->iocharset);
                        popt->iocharset = match_strdup(&args[0]);
+                       if (!popt->iocharset)
+                               return 0;
                        break;
 #endif
                case Opt_map_a: