sound/soc/qcom/qdsp6/q6usb.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
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>
---
Changes in v2:
- Propagate the error code returned by snd_soc_usb_allocate_port()
instead of an explicit -ENOMEM. [Dan Carpenter]
v1: https://lore.kernel.org/all/7338875b20cb41693f803c6b9673cf7f3e5f089a.1746781775.git.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 ebe0c2425927..0d998e872e82 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 = PTR_ERR(usb);
+ 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.50.0
On Sat, Jul 05, 2025 at 10:12:25AM +0200, Christophe JAILLET wrote: > 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. Well... Yes and no. It's better if we don't unnecessarily destroy devices in the probe path. I think a proper fix should be to move q6usb_dai_add_aux_device() after snd_soc_usb_allocate_port(). > > Fixes: 72b0b8b29980 ("ASoC: qcom: qdsp6: Add USB backend ASoC driver for Q6") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > --- > Changes in v2: > - Propagate the error code returned by snd_soc_usb_allocate_port() > instead of an explicit -ENOMEM. [Dan Carpenter] > > v1: https://lore.kernel.org/all/7338875b20cb41693f803c6b9673cf7f3e5f089a.1746781775.git.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 ebe0c2425927..0d998e872e82 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 = PTR_ERR(usb); > + 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.50.0 > -- With best wishes Dmitry
© 2016 - 2025 Red Hat, Inc.