2012-02-15 09:40:34

by Yong Zhang

[permalink] [raw]
Subject: [PATCH] usb gadget: fix race between eth_open() and gen_ndis_set_resp()

In such a scenario:
static int gen_ndis_set_resp()
{
...
switch (OID) {
case OID_GEN_CURRENT_PACKET_FILTER:
...
if (*params->filter) {
...
} else {
params->state = RNDIS_INITIALIZED;
netif_carrier_off(params->dev);
netif_stop_queue(params->dev); <=== A
}
}

After A is finished, if someone call 'ifconfig usb0 *.*.*.*',
usb0 will never go up because eth_open() fail to call eth_start();

Fix it by calling eth_start() unconditionally in eth_open().

Signed-off-by: Yong Zhang <[email protected]>
Cc: Felipe Balbi <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
---
drivers/usb/gadget/u_ether.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 29c854b..a1a666f 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -640,8 +640,7 @@ static int eth_open(struct net_device *net)
struct gether *link;

DBG(dev, "%s\n", __func__);
- if (netif_carrier_ok(dev->net))
- eth_start(dev, GFP_KERNEL);
+ eth_start(dev, GFP_KERNEL);

spin_lock_irq(&dev->lock);
link = dev->port_usb;
--
1.7.5.4