mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 04:10:18 +09:00
MIPS: vpe-cmp: fix possible memory leak while module exiting
[ Upstream commitc5ed1fe080] dev_set_name() allocates memory for name, it need be freed when module exiting, call put_device() to give up reference, so that it can be freed in kobject_cleanup() when the refcount hit to 0. The vpe_device is static, so remove kfree() from vpe_device_release(). Fixes:17a1d523aa("MIPS: APRP: Add VPE loader support for CMP platforms.") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
48d42f4464
commit
911773f08c
@@ -75,7 +75,6 @@ ATTRIBUTE_GROUPS(vpe);
|
|||||||
|
|
||||||
static void vpe_device_release(struct device *cd)
|
static void vpe_device_release(struct device *cd)
|
||||||
{
|
{
|
||||||
kfree(cd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct class vpe_class = {
|
static struct class vpe_class = {
|
||||||
@@ -157,6 +156,7 @@ out_dev:
|
|||||||
device_del(&vpe_device);
|
device_del(&vpe_device);
|
||||||
|
|
||||||
out_class:
|
out_class:
|
||||||
|
put_device(&vpe_device);
|
||||||
class_unregister(&vpe_class);
|
class_unregister(&vpe_class);
|
||||||
|
|
||||||
out_chrdev:
|
out_chrdev:
|
||||||
@@ -169,7 +169,7 @@ void __exit vpe_module_exit(void)
|
|||||||
{
|
{
|
||||||
struct vpe *v, *n;
|
struct vpe *v, *n;
|
||||||
|
|
||||||
device_del(&vpe_device);
|
device_unregister(&vpe_device);
|
||||||
class_unregister(&vpe_class);
|
class_unregister(&vpe_class);
|
||||||
unregister_chrdev(major, VPE_MODULE_NAME);
|
unregister_chrdev(major, VPE_MODULE_NAME);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user