Complete() will be run with interrupt enabled, so change to
spin_lock_irqsave().

Signed-off-by: Ming Lei <ming....@canonical.com>
---
 drivers/usb/misc/usbtest.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 8b4ca1c..5c73df5 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -804,11 +804,12 @@ static void ctrl_complete(struct urb *urb)
        struct usb_ctrlrequest  *reqp;
        struct subcase          *subcase;
        int                     status = urb->status;
+       unsigned long           flags;
 
        reqp = (struct usb_ctrlrequest *)urb->setup_packet;
        subcase = container_of(reqp, struct subcase, setup);
 
-       spin_lock(&ctx->lock);
+       spin_lock_irqsave(&ctx->lock, flags);
        ctx->count--;
        ctx->pending--;
 
@@ -907,7 +908,7 @@ error:
        /* signal completion when nothing's queued */
        if (ctx->pending == 0)
                complete(&ctx->complete);
-       spin_unlock(&ctx->lock);
+       spin_unlock_irqrestore(&ctx->lock, flags);
 }
 
 static int
@@ -1552,8 +1553,9 @@ struct iso_context {
 static void iso_callback(struct urb *urb)
 {
        struct iso_context      *ctx = urb->context;
+       unsigned long           flags;
 
-       spin_lock(&ctx->lock);
+       spin_lock_irqsave(&ctx->lock, flags);
        ctx->count--;
 
        ctx->packet_count += urb->number_of_packets;
@@ -1593,7 +1595,7 @@ static void iso_callback(struct urb *urb)
                complete(&ctx->done);
        }
 done:
-       spin_unlock(&ctx->lock);
+       spin_unlock_irqrestore(&ctx->lock, flags);
 }
 
 static struct urb *iso_alloc_urb(
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to