From f3cbb755a7b1d806b9714449b842537ebbb3d09e Mon Sep 17 00:00:00 2001 From: a17671 Date: Fri, 3 Aug 2018 17:11:23 +0800 Subject: [PATCH] moto_f_usbnet:Release skb if bulk_in is NULL Ip link tearing down is later than the usbnet disabling. Kernel will panic if bulk_in endpoint is NULL and ip stack still has data Free the skb in this case. Change-Id: Icc987551da4a8b9c1998b0c09f19fbed49ea58ee Signed-off-by: a17671 Reviewed-on: https://gerrit.mot.com/1220589 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Igor Kovalenko Submit-Approved: Jira Key --- drivers/moto_f_usbnet/f_usbnet.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/moto_f_usbnet/f_usbnet.c b/drivers/moto_f_usbnet/f_usbnet.c index e4d8bc6aa598..55d9ce884b89 100644 --- a/drivers/moto_f_usbnet/f_usbnet.c +++ b/drivers/moto_f_usbnet/f_usbnet.c @@ -349,6 +349,16 @@ static int usb_ether_xmit(struct sk_buff *skb, struct net_device *dev) unsigned len; int rc; + /*usbnet might be disabled before ip link down + * free the skb in this case + */ + if (NULL == context->bulk_in) { + dev_kfree_skb_any(skb); + USBNETDBG(context, + "%s:bulk_in end point is disabled\n", __func__); + return 0; + } + req = usb_get_xmit_request(STOP_QUEUE, dev); if (!req) {