diff mbox series

[02/14] ALSA: hdac: fix memory release for SST and SOF drivers

Message ID 20190605134556.10322-3-amadeuszx.slawinski@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Fix driver reload issues | expand

Commit Message

Amadeusz Sławiński June 5, 2019, 1:45 p.m. UTC
During the integration of HDaudio support, we changed the way in which
we get hdev in snd_hdac_ext_bus_device_init() to use one preallocated
with devm_kzalloc(), however it still left kfree(hdev) in
snd_hdac_ext_bus_device_exit(). It leads to oopses when trying to
rmmod and modprobe. Fix it, by just removing kfree call.

SOF also uses some of the snd_hdac_ functions for HDAudio support but
allocated the memory with kzalloc. A matching fix is provided
separately to align all users of the snd_hdac_ library.

Fixes: 6298542fa33b ("ALSA: hdac: remove memory allocation from snd_hdac_ext_bus_device_init")
Reviewed-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/hda/ext/hdac_ext_bus.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Pierre-Louis Bossart June 5, 2019, 3:06 p.m. UTC | #1
On 6/5/19 8:45 AM, Amadeusz Sławiński wrote:
> During the integration of HDaudio support, we changed the way in which
> we get hdev in snd_hdac_ext_bus_device_init() to use one preallocated
> with devm_kzalloc(), however it still left kfree(hdev) in
> snd_hdac_ext_bus_device_exit(). It leads to oopses when trying to
> rmmod and modprobe. Fix it, by just removing kfree call.
> 
> SOF also uses some of the snd_hdac_ functions for HDAudio support but
> allocated the memory with kzalloc. A matching fix is provided
> separately to align all users of the snd_hdac_ library.

There are stability issues with this change (already shared in a 
separate series) and additional findings reported by Libin so this 
should not be applied for now.

> 
> Fixes: 6298542fa33b ("ALSA: hdac: remove memory allocation from snd_hdac_ext_bus_device_init")
> Reviewed-by: Takashi Iwai <tiwai@suse.de>
> Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> ---
>   sound/hda/ext/hdac_ext_bus.c | 1 -
>   1 file changed, 1 deletion(-)
> 
> diff --git a/sound/hda/ext/hdac_ext_bus.c b/sound/hda/ext/hdac_ext_bus.c
> index c203af71a099..f33ba58b753c 100644
> --- a/sound/hda/ext/hdac_ext_bus.c
> +++ b/sound/hda/ext/hdac_ext_bus.c
> @@ -170,7 +170,6 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_init);
>   void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev)
>   {
>   	snd_hdac_device_exit(hdev);
> -	kfree(hdev);
>   }
>   EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_exit);
>   
>
Amadeusz Sławiński June 6, 2019, 12:57 p.m. UTC | #2
On Wed, 5 Jun 2019 10:06:47 -0500
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> wrote:

> On 6/5/19 8:45 AM, Amadeusz Sławiński wrote:
> > During the integration of HDaudio support, we changed the way in
> > which we get hdev in snd_hdac_ext_bus_device_init() to use one
> > preallocated with devm_kzalloc(), however it still left kfree(hdev)
> > in snd_hdac_ext_bus_device_exit(). It leads to oopses when trying to
> > rmmod and modprobe. Fix it, by just removing kfree call.
> > 
> > SOF also uses some of the snd_hdac_ functions for HDAudio support
> > but allocated the memory with kzalloc. A matching fix is provided
> > separately to align all users of the snd_hdac_ library.  
> 
> There are stability issues with this change (already shared in a 
> separate series) and additional findings reported by Libin so this 
> should not be applied for now.
> 

Yes, as mentioned in cover letter there is pending discussion, I
provided it for completeness.

> > 
> > Fixes: 6298542fa33b ("ALSA: hdac: remove memory allocation from
> > snd_hdac_ext_bus_device_init") Reviewed-by: Takashi Iwai
> > <tiwai@suse.de> Signed-off-by: Amadeusz Sławiński
> > <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Pierre-Louis
> > Bossart <pierre-louis.bossart@linux.intel.com> ---
> >   sound/hda/ext/hdac_ext_bus.c | 1 -
> >   1 file changed, 1 deletion(-)
> > 
> > diff --git a/sound/hda/ext/hdac_ext_bus.c
> > b/sound/hda/ext/hdac_ext_bus.c index c203af71a099..f33ba58b753c
> > 100644 --- a/sound/hda/ext/hdac_ext_bus.c
> > +++ b/sound/hda/ext/hdac_ext_bus.c
> > @@ -170,7 +170,6 @@ EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_init);
> >   void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev)
> >   {
> >   	snd_hdac_device_exit(hdev);
> > -	kfree(hdev);
> >   }
> >   EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_exit);
> >   
> >   
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
diff mbox series

Patch

diff --git a/sound/hda/ext/hdac_ext_bus.c b/sound/hda/ext/hdac_ext_bus.c
index c203af71a099..f33ba58b753c 100644
--- a/sound/hda/ext/hdac_ext_bus.c
+++ b/sound/hda/ext/hdac_ext_bus.c
@@ -170,7 +170,6 @@  EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_init);
 void snd_hdac_ext_bus_device_exit(struct hdac_device *hdev)
 {
 	snd_hdac_device_exit(hdev);
-	kfree(hdev);
 }
 EXPORT_SYMBOL_GPL(snd_hdac_ext_bus_device_exit);