[05/10] staging: most: usb: move allocation of URB out of critical section

Message ID 1590570387-27069-6-git-send-email-christian.gromm@microchip.com
State New
Headers show
Series
  • [01/10] staging: most: usb: change order of function parameters
Related show

Commit Message

Christian Gromm May 27, 2020, 9:06 a.m.
This patch puts the call to usb_alloc_urb() before the critical
section starts that is protected with the io_mutex lock. This is
to make the section as short as possible and to use the regular
GFP_KERNEL flag.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/staging/most/usb/usb.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Patch

diff --git a/drivers/staging/most/usb/usb.c b/drivers/staging/most/usb/usb.c
index a605e0f..534825f 100644
--- a/drivers/staging/most/usb/usb.c
+++ b/drivers/staging/most/usb/usb.c
@@ -467,18 +467,16 @@  static int hdm_enqueue(struct most_interface *iface, int channel,
 	if (iface->num_channels <= channel || channel < 0)
 		return -ECHRNG;
 
+	urb = usb_alloc_urb(NO_ISOCHRONOUS_URB, GFP_KERNEL);
+	if (!urb)
+		return -ENOMEM;
+
 	conf = &mdev->conf[channel];
 
 	mutex_lock(&mdev->io_mutex);
 	if (!mdev->usb_device) {
 		retval = -ENODEV;
-		goto unlock_io_mutex;
-	}
-
-	urb = usb_alloc_urb(NO_ISOCHRONOUS_URB, GFP_ATOMIC);
-	if (!urb) {
-		retval = -ENOMEM;
-		goto unlock_io_mutex;
+		goto err_free_urb;
 	}
 
 	if ((conf->direction & MOST_CH_TX) && mdev->padding_active[channel] &&