Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c9ffc787 authored by Harish Jenny K N's avatar Harish Jenny K N Committed by Felipe Balbi
Browse files

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: default avatarJim Baxter <jim_baxter@mentor.com>
Signed-off-by: default avatarHarish Jenny K N <harish_kandiga@mentor.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 79775f44
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -553,14 +553,16 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
		spin_lock_irqsave(&dev->lock, flags);
		spin_lock_irqsave(&dev->lock, flags);
		if (dev->port_usb)
		if (dev->port_usb)
			skb = dev->wrap(dev->port_usb, skb);
			skb = dev->wrap(dev->port_usb, skb);
		spin_unlock_irqrestore(&dev->lock, flags);
		if (!skb) {
		if (!skb) {
			/* Multi frame CDC protocols may store the frame for
			/* Multi frame CDC protocols may store the frame for
			 * later which is not a dropped frame.
			 * later which is not a dropped frame.
			 */
			 */
			if (dev->port_usb &&
			if (dev->port_usb &&
					dev->port_usb->supports_multi_frame)
					dev->port_usb->supports_multi_frame) {
				spin_unlock_irqrestore(&dev->lock, flags);
				goto multiframe;
				goto multiframe;
			}
			spin_unlock_irqrestore(&dev->lock, flags);
			goto drop;
			goto drop;
		}
		}
	}
	}
@@ -578,6 +580,7 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
		req->zero = 0;
		req->zero = 0;
	else
	else
		req->zero = 1;
		req->zero = 1;
	spin_unlock_irqrestore(&dev->lock, flags);


	/* use zlp framing on tx for strict CDC-Ether conformance,
	/* use zlp framing on tx for strict CDC-Ether conformance,
	 * though any robust network rx path ignores extra padding.
	 * though any robust network rx path ignores extra padding.