* Re: [PATCH] ALSA: hda: fix potential memleak in 'add_widget_node'
2022-11-10 14:45 ` Ye Bin
@ 2022-11-10 14:28 ` Takashi Iwai
-1 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2022-11-10 14:28 UTC (permalink / raw)
To: Ye Bin; +Cc: perex, tiwai, alsa-devel, yebin10, linux-kernel
On Thu, 10 Nov 2022 15:45:39 +0100,
Ye Bin wrote:
>
> From: Ye Bin <yebin10@huawei.com>
>
> 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>
Thanks, applied now.
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ALSA: hda: fix potential memleak in 'add_widget_node'
@ 2022-11-10 14:28 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2022-11-10 14:28 UTC (permalink / raw)
To: Ye Bin; +Cc: linux-kernel, alsa-devel, tiwai, yebin10
On Thu, 10 Nov 2022 15:45:39 +0100,
Ye Bin wrote:
>
> From: Ye Bin <yebin10@huawei.com>
>
> 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>
Thanks, applied now.
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] ALSA: hda: fix potential memleak in 'add_widget_node'
@ 2022-11-10 14:45 ` Ye Bin
0 siblings, 0 replies; 4+ messages in thread
From: Ye Bin @ 2022-11-10 14:45 UTC (permalink / raw)
To: perex, tiwai, alsa-devel; +Cc: yebin10, linux-kernel
From: Ye Bin <yebin10@huawei.com>
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>
---
sound/hda/hdac_sysfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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);
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ALSA: hda: fix potential memleak in 'add_widget_node'
@ 2022-11-10 14:45 ` Ye Bin
0 siblings, 0 replies; 4+ messages in thread
From: Ye Bin @ 2022-11-10 14:45 UTC (permalink / raw)
To: perex, tiwai, alsa-devel; +Cc: linux-kernel, yebin10
From: Ye Bin <yebin10@huawei.com>
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>
---
sound/hda/hdac_sysfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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);
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-10 19:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10 14:45 [PATCH] ALSA: hda: fix potential memleak in 'add_widget_node' Ye Bin
2022-11-10 14:45 ` Ye Bin
2022-11-10 14:28 ` Takashi Iwai
2022-11-10 14:28 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.