Skip to content

Commit 4c4e162

Browse files
pawellcdnsgregkh
authored andcommitted
usb: cdnsp: Fix lack of spin_lock_irqsave/spin_lock_restore
Patch puts content of cdnsp_gadget_pullup function inside spin_lock_irqsave and spin_lock_restore section. This construction is required here to keep the data consistency, otherwise some data can be changed e.g. from interrupt context. Fixes: 3d82904 ("usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver") Reported-by: Ken (Jian) He <[email protected]> cc: <[email protected]> Signed-off-by: Pawel Laszczak <[email protected]> -- Changelog: v2: - added disable_irq/enable_irq as sugester by Peter Chen drivers/usb/cdns3/cdnsp-gadget.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) Reviewed-by: Peter Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 0ad3bd5 commit 4c4e162

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/usb/cdns3/cdnsp-gadget.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,15 +1541,27 @@ static int cdnsp_gadget_pullup(struct usb_gadget *gadget, int is_on)
15411541
{
15421542
struct cdnsp_device *pdev = gadget_to_cdnsp(gadget);
15431543
struct cdns *cdns = dev_get_drvdata(pdev->dev);
1544+
unsigned long flags;
15441545

15451546
trace_cdnsp_pullup(is_on);
15461547

1548+
/*
1549+
* Disable events handling while controller is being
1550+
* enabled/disabled.
1551+
*/
1552+
disable_irq(cdns->dev_irq);
1553+
spin_lock_irqsave(&pdev->lock, flags);
1554+
15471555
if (!is_on) {
15481556
cdnsp_reset_device(pdev);
15491557
cdns_clear_vbus(cdns);
15501558
} else {
15511559
cdns_set_vbus(cdns);
15521560
}
1561+
1562+
spin_unlock_irqrestore(&pdev->lock, flags);
1563+
enable_irq(cdns->dev_irq);
1564+
15531565
return 0;
15541566
}
15551567

0 commit comments

Comments
 (0)