lkml.org 
[lkml]   [2022]   [May]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2022-05-12 17:48    [W:0.042 / U:0.280 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site