]> git.baikalelectronics.ru Git - kernel.git/commit
EDAC: Fix reference count leaks
authorQiushi Wu <wu000273@umn.edu>
Thu, 28 May 2020 20:22:37 +0000 (15:22 -0500)
committerBorislav Petkov <bp@suse.de>
Wed, 17 Jun 2020 13:38:35 +0000 (15:38 +0200)
commit11204c4dc699735a9bca0e96bbb8b59ddc97ba24
treecac6394e4118c2a5b2879200b76320793e8194b8
parent72daf91c8f61052181558f9b5da6ec641ee7a9a9
EDAC: Fix reference count leaks

When kobject_init_and_add() returns an error, it should be handled
because kobject_init_and_add() takes a reference even when it fails. If
this function returns an error, kobject_put() must be called to properly
clean up the memory associated with the object.

Therefore, replace calling kfree() and call kobject_put() and add a
missing kobject_put() in the edac_device_register_sysfs_main_kobj()
error path.

 [ bp: Massage and merge into a single patch. ]

Fixes: d381f399bf33 ("Kobject: change drivers/edac to use kobject_init_and_add")
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200528202238.18078-1-wu000273@umn.edu
Link: https://lkml.kernel.org/r/20200528203526.20908-1-wu000273@umn.edu
drivers/edac/edac_device_sysfs.c
drivers/edac/edac_pci_sysfs.c