Re: [PATCH 4.19 032/191] usb: gadget: udc: fix possible sleep-in-atomic-context bugs in gr_probe()

From: Pavel Machek
Date: Sun Feb 23 2020 - 05:34:17 EST


Hi!

> From: Jia-Ju Bai <baijiaju1990@xxxxxxxxx>
>
> [ Upstream commit 9c1ed62ae0690dfe5d5e31d8f70e70a95cb48e52 ]
>
> The driver may sleep while holding a spinlock.

True, but you can't just fix that by removing the locking.

> +++ b/drivers/usb/gadget/udc/gr_udc.c
> @@ -2180,8 +2180,6 @@ static int gr_probe(struct platform_device *pdev)
> return -ENOMEM;
> }
>
> - spin_lock(&dev->lock);
> -
> /* Inside lock so that no gadget can use this udc until probe is done */
> retval = usb_add_gadget_udc(dev->dev, &dev->gadget);
> if (retval) {

As this comment tries to explain. It is possible that the comment can
just be removed, but it looks like the code needs to be rearranged so
that rest of system does not see partly-initialized device.

Best regards,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Attachment: signature.asc
Description: Digital signature