Skip to content

Commit 9a5523f

Browse files
Ye Bintiwai
authored andcommitted
ALSA: hda: fix potential memleak in 'add_widget_node'
As 'kobject_add' may allocated memory for 'kobject->name' when return error. And in this function, if call 'kobject_add' failed didn't free kobject. So call 'kobject_put' to recycling resources. Signed-off-by: Ye Bin <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 9736a32 commit 9a5523f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sound/hda/hdac_sysfs.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,10 @@ static int add_widget_node(struct kobject *parent, hda_nid_t nid,
346346
return -ENOMEM;
347347
kobject_init(kobj, &widget_ktype);
348348
err = kobject_add(kobj, parent, "%02x", nid);
349-
if (err < 0)
349+
if (err < 0) {
350+
kobject_put(kobj);
350351
return err;
352+
}
351353
err = sysfs_create_group(kobj, group);
352354
if (err < 0) {
353355
kobject_put(kobj);

0 commit comments

Comments
 (0)