Skip to content

Commit 0602088

Browse files
XidianGeneralFelipe Balbi
authored andcommitted
usb: gadget: r8a66597: Fix two possible sleep-in-atomic-context bugs in init_controller()
The driver may sleep with holding a spinlock. The function call paths (from bottom to top) in Linux-4.16.7 are: [FUNC] msleep drivers/usb/gadget/udc/r8a66597-udc.c, 839: msleep in init_controller drivers/usb/gadget/udc/r8a66597-udc.c, 96: init_controller in r8a66597_usb_disconnect drivers/usb/gadget/udc/r8a66597-udc.c, 93: spin_lock in r8a66597_usb_disconnect [FUNC] msleep drivers/usb/gadget/udc/r8a66597-udc.c, 835: msleep in init_controller drivers/usb/gadget/udc/r8a66597-udc.c, 96: init_controller in r8a66597_usb_disconnect drivers/usb/gadget/udc/r8a66597-udc.c, 93: spin_lock in r8a66597_usb_disconnect To fix these bugs, msleep() is replaced with mdelay(). This bug is found by my static analysis tool (DSAC-2) and checked by my code review. Signed-off-by: Jia-Ju Bai <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent 50b9773 commit 0602088

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/usb/gadget/udc/r8a66597-udc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,11 +832,11 @@ static void init_controller(struct r8a66597 *r8a66597)
832832

833833
r8a66597_bset(r8a66597, XCKE, SYSCFG0);
834834

835-
msleep(3);
835+
mdelay(3);
836836

837837
r8a66597_bset(r8a66597, PLLC, SYSCFG0);
838838

839-
msleep(1);
839+
mdelay(1);
840840

841841
r8a66597_bset(r8a66597, SCKE, SYSCFG0);
842842

0 commit comments

Comments
 (0)