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

Commit f17f12ce authored by Mathias Krause's avatar Mathias Krause Committed by David Woodhouse
Browse files

mtd: phram: fix memory leak



Commit 4f678a58 (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: default avatarMathias Krause <minipli@googlemail.com>
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent 07be303d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ static void unregister_devices(void)
	list_for_each_entry_safe(this, safe, &phram_list, list) {
		del_mtd_device(&this->mtd);
		iounmap(this->mtd.priv);
		kfree(this->mtd.name);
		kfree(this);
	}
}
@@ -275,6 +276,8 @@ static int phram_setup(const char *val, struct kernel_param *kp)
	ret = register_device(name, start, len);
	if (!ret)
		pr_info("%s device: %#x at %#x\n", name, len, start);
	else
		kfree(name);

	return ret;
}