]> Git Repo - linux.git/commitdiff
ALSA: hda: fix potential memleak in 'add_widget_node'
authorYe Bin <[email protected]>
Thu, 10 Nov 2022 14:45:39 +0000 (22:45 +0800)
committerTakashi Iwai <[email protected]>
Thu, 10 Nov 2022 14:28:12 +0000 (15:28 +0100)
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]>
sound/hda/hdac_sysfs.c

index e47de49a32e3e4e93982f18ce5c6c29185014bc2..62a9615dcf529a241cef26c8319c156b49207757 100644 (file)
@@ -346,8 +346,10 @@ static int add_widget_node(struct kobject *parent, hda_nid_t nid,
                return -ENOMEM;
        kobject_init(kobj, &widget_ktype);
        err = kobject_add(kobj, parent, "%02x", nid);
-       if (err < 0)
+       if (err < 0) {
+               kobject_put(kobj);
                return err;
+       }
        err = sysfs_create_group(kobj, group);
        if (err < 0) {
                kobject_put(kobj);
This page took 0.059054 seconds and 4 git commands to generate.