From da0ce57aed4ba7b3763b471c01c4f5247e1cfae8 Mon Sep 17 00:00:00 2001 From: Rohith Kollalsi Date: Mon, 6 Sep 2021 20:27:24 +0530 Subject: [PATCH] USB: u_ether: Prevent unclocked access when running rndis interface down When in rndis composition, if device is disabled in device manager, usb enters low power mode. Then if rndis interface is put down, ep_disable is called leading to crash due to unclocked access as clocks are turned off when usb enters lpm. Fix this by waking up the controller, then performing ep_disable operation and then putting controller back to lpm. Change-Id: I45d29ef2e2678a3d6383d3fdd5550c8b8e156875 Signed-off-by: Rohith Kollalsi --- drivers/usb/gadget/function/u_ether.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index 3daf39be7f3c..bd8890914517 100644 --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -650,6 +650,8 @@ static int eth_stop(struct net_device *net) dev->net->stats.rx_errors, dev->net->stats.tx_errors ); + usb_gadget_autopm_get(dev->gadget); + /* ensure there are no more active requests */ spin_lock_irqsave(&dev->lock, flags); if (dev->port_usb) { @@ -682,6 +684,7 @@ static int eth_stop(struct net_device *net) } } spin_unlock_irqrestore(&dev->lock, flags); + usb_gadget_autopm_put_async(dev->gadget); return 0; }