Skip to contentSkip to conversation

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

PATCH Superseded Peter Ujfalusi 3 participants 4 messages Feb 20, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: hdmi-codec: Fix module unloading caused kernel crash

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.

---
 sound/soc/codecs/hdmi-codec.c | 12 ------------
 1 file changed, 12 deletions(-)
sound/soc/codecs/hdmi-codec.c +0 -12
index 42df579cb507..6fa11888672d 100644
@@ -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);
Signature · 4 lines
Peter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 5 lines · Peter Ujfalusi

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.

Quoted 8 lines

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.

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

Quoted 33 lines
---
 sound/soc/codecs/hdmi-codec.c | 12 ------------
 1 file changed, 12 deletions(-)
sound/soc/codecs/hdmi-codec.c +0 -12
index 42df579cb507..6fa11888672d 100644
@@ -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);
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
maintainer
#2 lore raw
In reply to Peter Ujfalusi
Quoted 3 lines · Peter Ujfalusi

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?

maintainer
#3 lore raw

Applied "ASoC: hdmi-codec: Fix module unloading caused kernel crash" to the asoc tree

In reply to Peter Ujfalusi

The patch

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

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From f1c680f5ef7ad3211bf1ae5630bd6a8219534e3c Mon Sep 17 00:00:00 2001

From: Peter Ujfalusi <[email protected]>
Date: Tue, 20 Feb 2018 14:30:10 +0200
Subject: [PATCH] ASoC: hdmi-codec: Fix module unloading caused kernel crash

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.

[Separate verison of the fix for -next -- broonie]

---
 sound/soc/codecs/hdmi-codec.c | 12 ------------
 1 file changed, 12 deletions(-)
sound/soc/codecs/hdmi-codec.c +0 -12
index 42df579cb507..6fa11888672d 100644
@@ -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);
Signature · 1 line
2.16.1