Messages in this thread | | | Date | Thu, 12 May 2022 17:46:32 +0200 | From | Borislav Petkov <> | Subject | Re: [PATCH v2] EDAC: Fix some refcount leaks |
| |
On Thu, May 12, 2022 at 11:59:06AM +0400, Miaoqian Lin wrote: > kobject_init_and_add() takes reference even when it fails. > According to the doc of kobject_init_and_add() > > If this function returns an error, kobject_put() must be called to > properly clean up the memory associated with the object. > > Fix this by calling kobject_put() when kobject_init_and_add() fails.
$ git grep -w kobject_init_and_add drivers/edac/ drivers/edac/edac_device_sysfs.c:259: err = kobject_init_and_add(&edac_dev->kobj, &ktype_device_ctrl, drivers/edac/edac_device_sysfs.c:538: err = kobject_init_and_add(&block->kobj, &ktype_block_ctrl, drivers/edac/edac_device_sysfs.c:637: err = kobject_init_and_add(&instance->kobj, &ktype_instance_ctrl, drivers/edac/edac_pci_sysfs.c:175: err = kobject_init_and_add(&pci->kobj, &ktype_pci_instance, drivers/edac/edac_pci_sysfs.c:372: err = kobject_init_and_add(edac_pci_top_main_kobj,
Wanna audit them all, make sure they all put the kobject properly and do a single patch fixing those which need fixing?
Thx.
-- Regards/Gruss, Boris.
https://people.kernel.org/tglx/notes-about-netiquette
| |