Skip to content

Commit f17f12c

Browse files
minipliDavid Woodhouse
authored andcommitted
mtd: phram: fix memory leak
Commit 4f678a5 (mtd: fix memory leaks in phram_setup) missed two cases where the memory allocated for name would be leaked. This commit frees the memory when register_device() fails and on unregister_devices(). Signed-off-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 07be303 commit f17f12c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎drivers/mtd/devices/phram.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ static void unregister_devices(void)
117117
list_for_each_entry_safe(this, safe, &phram_list, list) {
118118
del_mtd_device(&this->mtd);
119119
iounmap(this->mtd.priv);
120+
kfree(this->mtd.name);
120121
kfree(this);
121122
}
122123
}
@@ -275,6 +276,8 @@ static int phram_setup(const char *val, struct kernel_param *kp)
275276
ret = register_device(name, start, len);
276277
if (!ret)
277278
pr_info("%s device: %#x at %#x\n", name, len, start);
279+
else
280+
kfree(name);
278281

279282
return ret;
280283
}

0 commit comments

Comments
 (0)