diff mbox

ASoC: hdmi-codec: Fix module unloading caused kernel crash

Message ID 20180220123010.5373-1-peter.ujfalusi@ti.com (mailing list archive)
State Accepted
Commit f1c680f5ef7ad3211bf1ae5630bd6a8219534e3c
Headers show

Commit Message

Peter Ujfalusi Feb. 20, 2018, 12:30 p.m. UTC
The hcp->chmap_info must not be freed up in the hdmi_codec_remove()
function as it leads to kernel crash due ALSA core's
pcm_chmap_ctl_private_free() is trying to free it up again when the card
destroyed via snd_card_free.

Since the driver was converted to devm_snd_soc_register_component() the
whole platform_device.remove can be removed.

Commit cd6111b26280a ("ASoC: hdmi-codec: add channel mapping control")
should not have added the kfree(hcp->chmap_info); to the hdmi_codec_remove
function.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 sound/soc/codecs/hdmi-codec.c | 12 ------------
 1 file changed, 12 deletions(-)

Comments

Jyri Sarha Feb. 20, 2018, 12:37 p.m. UTC | #1
On 20/02/18 14:30, Peter Ujfalusi wrote:
> The hcp->chmap_info must not be freed up in the hdmi_codec_remove()
> function as it leads to kernel crash due ALSA core's
> pcm_chmap_ctl_private_free() is trying to free it up again when the card
> destroyed via snd_card_free.
> 
> Since the driver was converted to devm_snd_soc_register_component() the
> whole platform_device.remove can be removed.
> 
> Commit cd6111b26280a ("ASoC: hdmi-codec: add channel mapping control")
> should not have added the kfree(hcp->chmap_info); to the hdmi_codec_remove
> function.
> 
> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>

Thanks,
After this Beaglebone-black does not give "Unable to handle kernel
paging request" any more when unloading the tilcdc module.

Reviewed-by: Jyri Sarha <jsarha@ti.com>
Tested-by: Jyri Sarha <jsarha@ti.com>


> ---
>  sound/soc/codecs/hdmi-codec.c | 12 ------------
>  1 file changed, 12 deletions(-)
> 
> diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
> index 42df579cb507..6fa11888672d 100644
> --- a/sound/soc/codecs/hdmi-codec.c
> +++ b/sound/soc/codecs/hdmi-codec.c
> @@ -798,23 +798,11 @@ static int hdmi_codec_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -static int hdmi_codec_remove(struct platform_device *pdev)
> -{
> -	struct device *dev = &pdev->dev;
> -	struct hdmi_codec_priv *hcp;
> -
> -	hcp = dev_get_drvdata(dev);
> -	kfree(hcp->chmap_info);
> -
> -	return 0;
> -}
> -
>  static struct platform_driver hdmi_codec_driver = {
>  	.driver = {
>  		.name = HDMI_CODEC_DRV_NAME,
>  	},
>  	.probe = hdmi_codec_probe,
> -	.remove = hdmi_codec_remove,
>  };
>  
>  module_platform_driver(hdmi_codec_driver);
>
Mark Brown Feb. 20, 2018, 1:57 p.m. UTC | #2
On Tue, Feb 20, 2018 at 02:30:10PM +0200, Peter Ujfalusi wrote:

> Commit cd6111b26280a ("ASoC: hdmi-codec: add channel mapping control")
> should not have added the kfree(hcp->chmap_info); to the hdmi_codec_remove
> function.

That commit is in Linus' tree so this should go there too but this won't
apply against there as it's against -next with the component conversion,
could you respin on top of Linus' tree please?
diff mbox

Patch

diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c
index 42df579cb507..6fa11888672d 100644
--- a/sound/soc/codecs/hdmi-codec.c
+++ b/sound/soc/codecs/hdmi-codec.c
@@ -798,23 +798,11 @@  static int hdmi_codec_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int hdmi_codec_remove(struct platform_device *pdev)
-{
-	struct device *dev = &pdev->dev;
-	struct hdmi_codec_priv *hcp;
-
-	hcp = dev_get_drvdata(dev);
-	kfree(hcp->chmap_info);
-
-	return 0;
-}
-
 static struct platform_driver hdmi_codec_driver = {
 	.driver = {
 		.name = HDMI_CODEC_DRV_NAME,
 	},
 	.probe = hdmi_codec_probe,
-	.remove = hdmi_codec_remove,
 };
 
 module_platform_driver(hdmi_codec_driver);