Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ASoC: qcom: qdsp6: Add an error handling path in q6usb_component_probe()
@ 2025-05-09  9:09 Christophe JAILLET
  2025-05-09 10:07 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Christophe JAILLET @ 2025-05-09  9:09 UTC (permalink / raw)
  To: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Greg Kroah-Hartman, Wesley Cheng
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-sound,
	linux-arm-msm

If an error occurs after a successful q6usb_dai_add_aux_device() call,
some resources should be released as already done in the remove function.

Add an error handling path in the probe and the missing clean-up.

Fixes: 72b0b8b29980 ("ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 sound/soc/qcom/qdsp6/q6usb.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/sound/soc/qcom/qdsp6/q6usb.c b/sound/soc/qcom/qdsp6/q6usb.c
index adba0446f301..8044cb7e4dd8 100644
--- a/sound/soc/qcom/qdsp6/q6usb.c
+++ b/sound/soc/qcom/qdsp6/q6usb.c
@@ -327,8 +327,10 @@ static int q6usb_component_probe(struct snd_soc_component *component)
 		return ret;
 
 	usb = snd_soc_usb_allocate_port(component, &data->priv);
-	if (IS_ERR(usb))
-		return -ENOMEM;
+	if (IS_ERR(usb)) {
+		ret = -ENOMEM;
+		goto free_aux_devices;
+	}
 
 	usb->connection_status_cb = q6usb_alsa_connection_cb;
 	usb->update_offload_route_info = q6usb_update_offload_route;
@@ -337,6 +339,12 @@ static int q6usb_component_probe(struct snd_soc_component *component)
 	data->usb = usb;
 
 	return 0;
+
+free_aux_devices:
+	auxiliary_device_delete(&data->uauxdev);
+	auxiliary_device_uninit(&data->uauxdev);
+
+	return ret;
 }
 
 static void q6usb_component_remove(struct snd_soc_component *component)
-- 
2.49.0


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

* Re: [PATCH] ASoC: qcom: qdsp6: Add an error handling path in q6usb_component_probe()
  2025-05-09  9:09 [PATCH] ASoC: qcom: qdsp6: Add an error handling path in q6usb_component_probe() Christophe JAILLET
@ 2025-05-09 10:07 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2025-05-09 10:07 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Greg Kroah-Hartman, Wesley Cheng, linux-kernel,
	kernel-janitors, linux-sound, linux-arm-msm

On Fri, May 09, 2025 at 11:09:55AM +0200, Christophe JAILLET wrote:
>  sound/soc/qcom/qdsp6/q6usb.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/qcom/qdsp6/q6usb.c b/sound/soc/qcom/qdsp6/q6usb.c
> index adba0446f301..8044cb7e4dd8 100644
> --- a/sound/soc/qcom/qdsp6/q6usb.c
> +++ b/sound/soc/qcom/qdsp6/q6usb.c
> @@ -327,8 +327,10 @@ static int q6usb_component_probe(struct snd_soc_component *component)
>  		return ret;
>  
>  	usb = snd_soc_usb_allocate_port(component, &data->priv);
> -	if (IS_ERR(usb))
> -		return -ENOMEM;
> +	if (IS_ERR(usb)) {
> +		ret = -ENOMEM;

ret = PTR_ERR(usb)?

> +		goto free_aux_devices;
> +	}

regards,
dan carpenter


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

end of thread, other threads:[~2025-05-09 10:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-09  9:09 [PATCH] ASoC: qcom: qdsp6: Add an error handling path in q6usb_component_probe() Christophe JAILLET
2025-05-09 10:07 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox