All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda - Fix memory leak on snd_hdac_device_init error
@ 2017-11-09  3:27 Guneshwor Singh
  2017-11-09  4:44 ` Vinod Koul
  0 siblings, 1 reply; 4+ messages in thread
From: Guneshwor Singh @ 2017-11-09  3:27 UTC (permalink / raw)
  To: ALSA ML, Takashi Iwai
  Cc: Vinod Koul, Guneshwor Singh, Liam Girdwood, Patches Audio,
	Mark Brown, Subhransu S. Prusty

From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>

Free codec vendor name on snd_hdac_device_init error.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
---
 sound/hda/hdac_device.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c
index 19deb306facb..467b949544e2 100644
--- a/sound/hda/hdac_device.c
+++ b/sound/hda/hdac_device.c
@@ -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;
 }
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ALSA: hda - Fix memory leak on snd_hdac_device_init error
  2017-11-09  3:27 [PATCH] ALSA: hda - Fix memory leak on snd_hdac_device_init error Guneshwor Singh
@ 2017-11-09  4:44 ` Vinod Koul
  2017-11-09  7:31   ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Vinod Koul @ 2017-11-09  4:44 UTC (permalink / raw)
  To: Guneshwor Singh
  Cc: ALSA ML, Takashi Iwai, Liam Girdwood, Patches Audio, Mark Brown,
	Subhransu S. Prusty

On Thu, Nov 09, 2017 at 08:57:51AM +0530, Guneshwor Singh wrote:
> From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
> 
> Free codec vendor name on snd_hdac_device_init error.
> 
> Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
> Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
> ---
>  sound/hda/hdac_device.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c
> index 19deb306facb..467b949544e2 100644
> --- a/sound/hda/hdac_device.c
> +++ b/sound/hda/hdac_device.c
> @@ -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.

>  	put_device(&codec->dev);
>  	return err;
>  }
> -- 
> 2.15.0
> 

-- 
~Vinod

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ALSA: hda - Fix memory leak on snd_hdac_device_init error
  2017-11-09  4:44 ` Vinod Koul
@ 2017-11-09  7:31   ` Takashi Iwai
  2017-11-09 11:29     ` Singh, Guneshwor
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2017-11-09  7:31 UTC (permalink / raw)
  To: Vinod Koul
  Cc: ALSA ML, Patches Audio, Guneshwor Singh, Liam Girdwood,
	Mark Brown, Subhransu S. Prusty

On Thu, 09 Nov 2017 05:44:19 +0100,
Vinod Koul wrote:
> 
> On Thu, Nov 09, 2017 at 08:57:51AM +0530, Guneshwor Singh wrote:
> > From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
> > 
> > Free codec vendor name on snd_hdac_device_init error.
> > 
> > Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
> > Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
> > ---
> >  sound/hda/hdac_device.c | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c
> > index 19deb306facb..467b949544e2 100644
> > --- a/sound/hda/hdac_device.c
> > +++ b/sound/hda/hdac_device.c
> > @@ -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.

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


thanks,

Takashi


> 
> >  	put_device(&codec->dev);
> >  	return err;
> >  }
> > -- 
> > 2.15.0
> > 
> 
> -- 
> ~Vinod
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ALSA: hda - Fix memory leak on snd_hdac_device_init error
  2017-11-09  7:31   ` Takashi Iwai
@ 2017-11-09 11:29     ` Singh, Guneshwor
  0 siblings, 0 replies; 4+ messages in thread
From: Singh, Guneshwor @ 2017-11-09 11:29 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: ALSA ML, Vinod Koul, Liam Girdwood, Patches Audio, Mark Brown,
	Subhransu S. Prusty

On Thu, Nov 09, 2017 at 08:31:56AM +0100, Takashi Iwai wrote:
> On Thu, 09 Nov 2017 05:44:19 +0100,
> Vinod Koul wrote:
> > 
> > On Thu, Nov 09, 2017 at 08:57:51AM +0530, Guneshwor Singh wrote:
> > > From: "Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
> > > 
> > > Free codec vendor name on snd_hdac_device_init error.
> > > 
> > > Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
> > > Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
> > > ---
> > >  sound/hda/hdac_device.c | 2 ++
> > >  1 file changed, 2 insertions(+)
> > > 
> > > diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c
> > > index 19deb306facb..467b949544e2 100644
> > > --- a/sound/hda/hdac_device.c
> > > +++ b/sound/hda/hdac_device.c
> > > @@ -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.
> 
> Correct.  The patch would lead to a double-free.
> 
> 

Yes, you are right. Please ignore the patch.

> thanks,
> 
> Takashi
> 
> 
> > 
> > >  	put_device(&codec->dev);
> > >  	return err;
> > >  }
> > > -- 
> > > 2.15.0
> > > 
> > 
> > -- 
> > ~Vinod
> > 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-09 11:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-09  3:27 [PATCH] ALSA: hda - Fix memory leak on snd_hdac_device_init error Guneshwor Singh
2017-11-09  4:44 ` Vinod Koul
2017-11-09  7:31   ` Takashi Iwai
2017-11-09 11:29     ` Singh, Guneshwor

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.