aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarish Jenny K N <harish_kandiga@mentor.com>2016-09-09 05:30:42 -0400
committerFelipe Balbi <felipe.balbi@linux.intel.com>2016-09-09 07:49:20 -0400
commitc9ffc78745f89e300fe704348dd8e6800acf4d18 (patch)
treee70891db457aa3c4d4ce882e1d612c20d89def65
parent79775f441838403be856e06eaab893a3fe9dd7b2 (diff)
usb: gadget: NCM: Protect dev->port_usb using dev->lock
This commit incorporates findings from https://lkml.org/lkml/2016/4/25/594 The function has been modified to make sure we hold the dev lock when accessing the net device pointer. Acked-by: Jim Baxter <jim_baxter@mentor.com> Signed-off-by: Harish Jenny K N <harish_kandiga@mentor.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
-rw-r--r--drivers/usb/gadget/function/u_ether.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c
index 9c8c9ed1dc9e..8cb08033b7c1 100644
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -553,14 +553,16 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
553 spin_lock_irqsave(&dev->lock, flags); 553 spin_lock_irqsave(&dev->lock, flags);
554 if (dev->port_usb) 554 if (dev->port_usb)
555 skb = dev->wrap(dev->port_usb, skb); 555 skb = dev->wrap(dev->port_usb, skb);
556 spin_unlock_irqrestore(&dev->lock, flags);
557 if (!skb) { 556 if (!skb) {
558 /* Multi frame CDC protocols may store the frame for 557 /* Multi frame CDC protocols may store the frame for
559 * later which is not a dropped frame. 558 * later which is not a dropped frame.
560 */ 559 */
561 if (dev->port_usb && 560 if (dev->port_usb &&
562 dev->port_usb->supports_multi_frame) 561 dev->port_usb->supports_multi_frame) {
562 spin_unlock_irqrestore(&dev->lock, flags);
563 goto multiframe; 563 goto multiframe;
564 }
565 spin_unlock_irqrestore(&dev->lock, flags);
564 goto drop; 566 goto drop;
565 } 567 }
566 } 568 }
@@ -578,6 +580,7 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
578 req->zero = 0; 580 req->zero = 0;
579 else 581 else
580 req->zero = 1; 582 req->zero = 1;
583 spin_unlock_irqrestore(&dev->lock, flags);
581 584
582 /* use zlp framing on tx for strict CDC-Ether conformance, 585 /* use zlp framing on tx for strict CDC-Ether conformance,
583 * though any robust network rx path ignores extra padding. 586 * though any robust network rx path ignores extra padding.