Skip to contentSkip to conversation

ALSA: hda - Fix memory leak on snd_hdac_device_init error

PATCH In review Guneshwor Singh 3 participants 4 messages Nov 9, 2017 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: hda - Fix memory leak on snd_hdac_device_init error

From: "Subhransu S. Prusty" <[email protected]>

Free codec vendor name on snd_hdac_device_init error.

---
 sound/hda/hdac_device.c | 2 ++
 1 file changed, 2 insertions(+)
sound/hda/hdac_device.c +2 -0
index 19deb306facb..467b949544e2 100644
@@ -111,6 +111,8 @@ int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus,
 	return 0;
 
  error:
+	kfree(codec->vendor_name);
+
 	put_device(&codec->dev);
 	return err;
 }
Signature · 1 line
2.15.0
#1 lore raw
Quoted 15 lines · Guneshwor Singh

From: "Subhransu S. Prusty" <[email protected]>

Free codec vendor name on snd_hdac_device_init error.

---
 sound/hda/hdac_device.c | 2 ++
 1 file changed, 2 insertions(+)
sound/hda/hdac_device.c +0 -0
index 19deb306facb..467b949544e2 100644

sound/hda/hdac_device.c int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus, · line 114

Quoted 4 lines
sound/hda/hdac_device.c +1 -0
@@ -111,6 +111,8 @@ int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus,
 	return 0;
 
  error:
+	kfree(codec->vendor_name);

Sorry I dont think this is right.

The vendor name is freed in the snd_hdac_device_exit()

We drop the reference here and release method would be called to free up the resources.

Quoted 6 lines
sound/hda/hdac_device.c +0 -0
 	put_device(&codec->dev);
 	return err;
 }
Signature · 1 line
2.15.0
Signature · 1 line
~Vinod
#2 lore raw
Quoted 24 lines · Vinod Koul
Quoted 15 lines · Guneshwor Singh

From: "Subhransu S. Prusty" <[email protected]>

Free codec vendor name on snd_hdac_device_init error.

---
 sound/hda/hdac_device.c | 2 ++
 1 file changed, 2 insertions(+)
sound/hda/hdac_device.c +0 -0
index 19deb306facb..467b949544e2 100644

sound/hda/hdac_device.c int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus, · line 114

Quoted 4 lines
sound/hda/hdac_device.c +1 -0
@@ -111,6 +111,8 @@ int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus,
 	return 0;
 
  error:
+	kfree(codec->vendor_name);

Sorry I dont think this is right.

Quoted 4 lines

The vendor name is freed in the snd_hdac_device_exit()

We drop the reference here and release method would be called to free up the resources.

Correct. The patch would lead to a double-free.

thanks,

Takashi

Quoted 11 lines
Quoted 7 lines
sound/hda/hdac_device.c +0 -0
 	put_device(&codec->dev);
 	return err;
 }
Signature · 1 line
2.15.0
Signature · 1 line
~Vinod
#3 lore raw
Quoted 26 lines · Takashi Iwai
Quoted 24 lines · Vinod Koul
Quoted 15 lines · Guneshwor Singh

From: "Subhransu S. Prusty" <[email protected]>

Free codec vendor name on snd_hdac_device_init error.

---
 sound/hda/hdac_device.c | 2 ++
 1 file changed, 2 insertions(+)
sound/hda/hdac_device.c +0 -0
index 19deb306facb..467b949544e2 100644

sound/hda/hdac_device.c int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus, · line 114

Quoted 4 lines
sound/hda/hdac_device.c +1 -0
@@ -111,6 +111,8 @@ int snd_hdac_device_init(struct hdac_device *codec, struct hdac_bus *bus,
 	return 0;
 
  error:
+	kfree(codec->vendor_name);

Sorry I dont think this is right.

Quoted 8 lines
Quoted 4 lines

The vendor name is freed in the snd_hdac_device_exit()

We drop the reference here and release method would be called to free up the resources.

Correct. The patch would lead to a double-free.

Yes, you are right. Please ignore the patch.

Quoted 16 lines

thanks,

Takashi

Quoted 11 lines
Quoted 7 lines
sound/hda/hdac_device.c +0 -0
 	put_device(&codec->dev);
 	return err;
 }
Signature · 1 line
2.15.0
Signature · 1 line
~Vinod