Skip to contentSkip to conversation

ASoC: fsl: imx-audio-rpmsg: unregister platform devices on probe failure

PATCH In review Wentao Liang 2 participants 2 messages Nov 4 – Nov 9

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: fsl: imx-audio-rpmsg: unregister platform devices on probe failure

imx_audio_rpmsg_probe() registers the rpmsg platform device and the card platform device, but when a registration fails it only records the error code and continues to the next step. The rpmsg core does not call remove for a probe that failed, so a card device registered after the rpmsg device registration failed stays registered forever. The reverse case is just as bad: if the card registration fails, the already registered rpmsg device is never unregistered.

Return immediately when the rpmsg device cannot be registered, and unregister that device before returning when the card device cannot be registered.

Fixes c73524768e9e ("ASoC: fsl: Let imx-audio-rpmsg register platform device for card")
Assisted-by DeepSeek-V4.1-Flash and OpenAI Codex
---
 sound/soc/fsl/imx-audio-rpmsg.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
sound/soc/fsl/imx-audio-rpmsg.c +5 -2
index b55dfbdb4502..950bf9e5b648 100644
@@ -92,7 +92,7 @@ static int imx_audio_rpmsg_probe(struct rpmsg_device *rpdev)
 							 NULL, 0);
 	if (IS_ERR(data->rpmsg_pdev)) {
 		dev_err(&rpdev->dev, "failed to register rpmsg platform.\n");
-		ret = PTR_ERR(data->rpmsg_pdev);
+		return PTR_ERR(data->rpmsg_pdev);
 	}
 
 	data->card_pdev = platform_device_register_data(&rpdev->dev,
@@ -103,9 +103,12 @@ static int imx_audio_rpmsg_probe(struct rpmsg_device *rpdev)
 	if (IS_ERR(data->card_pdev)) {
 		dev_err(&rpdev->dev, "failed to register rpmsg card.\n");
 		ret = PTR_ERR(data->card_pdev);
+		platform_device_unregister(data->rpmsg_pdev);
+		data->rpmsg_pdev = NULL;
+		return ret;
 	}
 
-	return ret;
+	return 0;
 }
 
 static void imx_audio_rpmsg_remove(struct rpmsg_device *rpdev)
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 1 line · Wentao Liang

ASoC: fsl: imx-audio-rpmsg: unregister platform devices on probe failure

Applied to

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

Thanks!

[1/1] ASoC: fsl: imx-audio-rpmsg: unregister platform devices on probe failure

      https://git.kernel.org/broonie/sound/c/a3aa7ec56c14

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