Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756579AbcDNQdx (ORCPT ); Thu, 14 Apr 2016 12:33:53 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:35108 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756433AbcDNQdv (ORCPT ); Thu, 14 Apr 2016 12:33:51 -0400 From: Tal Shorer To: b-liu@ti.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Tal Shorer Subject: [PATCH 1/1] usb: musb: gadget: nuke endpoint before setting its descriptor to NULL Date: Thu, 14 Apr 2016 19:33:43 +0300 Message-Id: <1460651623-7022-2-git-send-email-tal.shorer@gmail.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1460651623-7022-1-git-send-email-tal.shorer@gmail.com> References: <1460651623-7022-1-git-send-email-tal.shorer@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 929 Lines: 31 Some functions, such as f_sourcesink, rely on an endpoint's desc field during their requests' complete() callback, so clear it only _after_ nuking all requests to avoid NULL pointer dereference. Signed-off-by: Tal Shorer --- drivers/usb/musb/musb_gadget.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 87bd578..152865b 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1164,12 +1164,12 @@ static int musb_gadget_disable(struct usb_ep *ep) musb_writew(epio, MUSB_RXMAXP, 0); } - musb_ep->desc = NULL; - musb_ep->end_point.desc = NULL; - /* abort all pending DMA and requests */ nuke(musb_ep, -ESHUTDOWN); + musb_ep->desc = NULL; + musb_ep->end_point.desc = NULL; + schedule_work(&musb->irq_work); spin_unlock_irqrestore(&(musb->lock), flags); -- 2.5.0