summaryrefslogtreecommitdiff
path: root/sound/hda
diff options
context:
space:
mode:
authorYe Bin <yebin10@huawei.com>2022-11-10 22:45:39 +0800
committerTakashi Iwai <tiwai@suse.de>2022-11-10 15:28:12 +0100
commit9a5523f72bd2b0d66eef3d58810c6eb7b5ffc143 (patch)
tree95e0f4d07b7317848f25af774767b70a6aed2915 /sound/hda
parent9736a325137b62499d2b4be3fc2d742b131f75da (diff)
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 <yebin10@huawei.com> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20221110144539.2989354-1-yebin@huaweicloud.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/hda')
-rw-r--r--sound/hda/hdac_sysfs.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sound/hda/hdac_sysfs.c b/sound/hda/hdac_sysfs.c
index e47de49a32e3..62a9615dcf52 100644
--- a/sound/hda/hdac_sysfs.c
+++ b/sound/hda/hdac_sysfs.c
@@ -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);