All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] usb: gadget: f_uac2: fix error handling at afunc_bind
@ 2016-10-26  8:46 Peter Chen
  2016-11-03  8:50 ` Felipe Balbi
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Chen @ 2016-10-26  8:46 UTC (permalink / raw)
  To: balbi; +Cc: linux-usb, Peter Chen, stable

The current error handling flow uses incorrect goto label, fix it

Cc: <stable@vger.kernel.org>
Fixes: d12a8727171c ("usb: gadget: function: Remove
	redundant usb_free_all_descriptors")
Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
 drivers/usb/gadget/function/f_uac2.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c
index cd214ec8..3f4e478 100644
--- a/drivers/usb/gadget/function/f_uac2.c
+++ b/drivers/usb/gadget/function/f_uac2.c
@@ -1067,13 +1067,13 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
 	agdev->out_ep = usb_ep_autoconfig(gadget, &fs_epout_desc);
 	if (!agdev->out_ep) {
 		dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
-		goto err;
+		return ret;
 	}
 
 	agdev->in_ep = usb_ep_autoconfig(gadget, &fs_epin_desc);
 	if (!agdev->in_ep) {
 		dev_err(dev, "%s:%d Error!\n", __func__, __LINE__);
-		goto err;
+		return ret;
 	}
 
 	uac2->p_prm.uac2 = uac2;
@@ -1091,13 +1091,14 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
 	ret = usb_assign_descriptors(fn, fs_audio_desc, hs_audio_desc, NULL,
 				     NULL);
 	if (ret)
-		goto err;
+		return ret;
 
 	prm = &agdev->uac2.c_prm;
 	prm->max_psize = hs_epout_desc.wMaxPacketSize;
 	prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL);
 	if (!prm->rbuf) {
 		prm->max_psize = 0;
+		ret = -ENOMEM;
 		goto err_free_descs;
 	}
 
@@ -1106,20 +1107,21 @@ afunc_bind(struct usb_configuration *cfg, struct usb_function *fn)
 	prm->rbuf = kzalloc(prm->max_psize * USB_XFERS, GFP_KERNEL);
 	if (!prm->rbuf) {
 		prm->max_psize = 0;
-		goto err_free_descs;
+		ret = -ENOMEM;
+		goto err_no_memory;
 	}
 
 	ret = alsa_uac2_init(agdev);
 	if (ret)
-		goto err_free_descs;
+		goto err_no_memory;
 	return 0;
 
-err_free_descs:
-	usb_free_all_descriptors(fn);
-err:
+err_no_memory:
 	kfree(agdev->uac2.p_prm.rbuf);
 	kfree(agdev->uac2.c_prm.rbuf);
-	return -EINVAL;
+err_free_descs:
+	usb_free_all_descriptors(fn);
+	return ret;
 }
 
 static int
-- 
2.7.4


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

end of thread, other threads:[~2016-11-03  9:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-26  8:46 [PATCH 1/1] usb: gadget: f_uac2: fix error handling at afunc_bind Peter Chen
2016-11-03  8:50 ` Felipe Balbi
2016-11-03  9:20   ` Peter Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.