Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a6550e57 authored by Jesper Juhl's avatar Jesper Juhl Committed by David Woodhouse
Browse files

mtd: fix memory leak in block2mtd_setup()



There's a mem leak in drivers/mtd/devices/block2mtd.c::block2mtd_setup()

We can leak 'name' allocated with kmalloc in 'parse_name' if leave via
the 'parse_err' macro since it contains a return but doesn't do any
freeing.

Spotted by coverity checker as bug 615.

Signed-off-by: default avatarJesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent 552d9205
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -429,7 +429,8 @@ static inline void kill_final_newline(char *str)

static int block2mtd_setup(const char *val, struct kernel_param *kp)
{
	char buf[80+12], *str=buf; /* 80 for device, 12 for erase size */
	char buf[80+12]; /* 80 for device, 12 for erase size */
	char *str = buf;
	char *token[2];
	char *name;
	size_t erase_size = PAGE_SIZE;
@@ -460,9 +461,11 @@ static int block2mtd_setup(const char *val, struct kernel_param *kp)

	if (token[1]) {
		ret = parse_num(&erase_size, token[1]);
		if (ret)
		if (ret) {
			kfree(name);
			parse_err("illegal erase size");
		}
	}

	add_device(name, erase_size);