From patchwork Mon Aug 15 07:00:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 73897 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1307917qga; Mon, 15 Aug 2016 00:01:52 -0700 (PDT) X-Received: by 10.98.71.140 with SMTP id p12mr51150976pfi.93.1471244512660; Mon, 15 Aug 2016 00:01:52 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g63si25175067pfg.227.2016.08.15.00.01.52; Mon, 15 Aug 2016 00:01:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751233AbcHOHBu (ORCPT + 4 others); Mon, 15 Aug 2016 03:01:50 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:35177 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751488AbcHOHBt (ORCPT ); Mon, 15 Aug 2016 03:01:49 -0400 Received: by mail-pf0-f181.google.com with SMTP id x72so14872547pfd.2 for ; Mon, 15 Aug 2016 00:01:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=TQA+BxwE0l1Jh89SsH76MTUb4g+j1vigkUyWdpgMSoY=; b=SAhq8XBsIDZL34ds4fbEXEUMtSkjSYbYJwFYmf8ysXc/YKzv3mJ8fJJki/MWwB6vDt cjfFDQIrP9dH9bETwlA+uSD+hpaAueOikG0btZxoeAhqvN64Hff4njwrSI88VNpWOWvU WG9n6S9429W64CR9CDbhrdPWL8Oiu+VkJ3meA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TQA+BxwE0l1Jh89SsH76MTUb4g+j1vigkUyWdpgMSoY=; b=f0oj7vWIIF2gYkI+YCgCFwR5ilzduwWx1b8DnxcLYttp0m7LZzn7XVhxMZKfmuB4YG TwZhl1ny5gu9qRB2UVYGm+gkIHp1tAUkFB0zFqsvaTF1/Tg89aEbWF2N4flRAVbhCQTq Dk9nvWbX4zwHrMTNIMFUNDVairom5A3k7mOzSvWm27MiGRJzqO2h6Y7EMSbLp5YoULhH 7utUy2pwWNjDFyCbnvP/tmhMJqMyhXa863FU87ZlHd/PHf8BaL1dLJaejDx4C5Lp2jSg Ht+R8P/mYXNdlezQOukpvxr0sT4XvzNjCqVjtM0YrJxJ0YuqVFcNeIjeoN9IIxWsSxim +7ug== X-Gm-Message-State: AEkoouuYbvVpWgWz6CrUdn9Xw2JG+qmTxGzDBfuFBBElW4PttRliKTtKoX7ULioqCMIkFgf3 X-Received: by 10.98.207.6 with SMTP id b6mr51338042pfg.25.1471244509048; Mon, 15 Aug 2016 00:01:49 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id 81sm29729739pfm.90.2016.08.15.00.01.45 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Aug 2016 00:01:48 -0700 (PDT) From: Baolin Wang To: balbi@kernel.org, gregkh@linuxfoundation.org Cc: peter@hurleysoftware.com, r.baldyga@samsung.com, broonie@kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, baolin.wang@linaro.org Subject: [RESEND PATCH] usb: gadget: Add the gserial port checking in gs_start_tx() Date: Mon, 15 Aug 2016 15:00:38 +0800 Message-Id: <11cb15ff2587d4f38f72bfdb3d5650144ba150ef.1467277321.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When usb gadget is set gadget serial function, it will be crash in below situation. It will clean the 'port->port_usb' pointer in gserial_disconnect() function when usb link is inactive, but it will release lock for disabling the endpoints in this function. Druing the lock release period, it maybe complete one request to issue gs_write_complete()--->gs_start_tx() function, but the 'port->port_usb' pointer had been set NULL, thus it will be crash in gs_start_tx() function. This patch adds the 'port->port_usb' pointer checking in gs_start_tx() function to avoid this situation. Signed-off-by: Baolin Wang --- drivers/usb/gadget/function/u_serial.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/gadget/function/u_serial.c b/drivers/usb/gadget/function/u_serial.c index 3580f19..66a0910 100644 --- a/drivers/usb/gadget/function/u_serial.c +++ b/drivers/usb/gadget/function/u_serial.c @@ -375,10 +375,15 @@ __acquires(&port->port_lock) */ { struct list_head *pool = &port->write_pool; - struct usb_ep *in = port->port_usb->in; + struct usb_ep *in; int status = 0; bool do_tty_wake = false; + if (!port->port_usb) + return status; + + in = port->port_usb->in; + while (!port->write_busy && !list_empty(pool)) { struct usb_request *req; int len;