From patchwork Tue May 13 09:27:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 30010 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 875CE20369 for ; Tue, 13 May 2014 09:38:43 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id i7sf397962oag.0 for ; Tue, 13 May 2014 02:38:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=GAsaY9CAXh32xnkYcTTOzxBSuFUCi494fmVnA+NI4oA=; b=Ykm4kC9+Epym9dB5SurR9Z3vF+MAgiOYbwnG10lvL0r5FzlNatqb4nZIEstPIci6F0 zj0bdNGTkaQBXXX4yovgrffBGJ6gUgiBlf9KC93JpdjHJFntPWpRoPJWZ8j0ig6mIa6J A78vyoJU261n7zZH1KmrJ1nWw2DyZO0D84FQ7OuSoAjqMuPp2qYWRAAJslEivPjVx34T eo7rNuVXgp2ggI10QbBx7MjsmD1tZpQ1tnySJ12XvN75JM0WgRXdU01GN0cs630Siiqt f+sSXTzuQD/NIJIKJu+KHurL2D4SUrbs2d06MCYyI25lDUCXx+Qmc5bBcL1DmPk9zKQF jBdw== X-Gm-Message-State: ALoCoQnlNdRSbTJRAOhiMfvU/8fMHnzIFkUlL1cCQALh3ghy6LzDjhqRxasY7ENfNp02Ju1UWwwo X-Received: by 10.42.30.71 with SMTP id u7mr4177624icc.15.1399973923083; Tue, 13 May 2014 02:38:43 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.83.240 with SMTP id j103ls1749037qgd.47.gmail; Tue, 13 May 2014 02:38:43 -0700 (PDT) X-Received: by 10.52.141.74 with SMTP id rm10mr23620272vdb.6.1399973922998; Tue, 13 May 2014 02:38:42 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id mz3si2547352vcb.138.2014.05.13.02.38.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 02:38:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.182 as permitted sender) client-ip=209.85.128.182; Received: by mail-ve0-f182.google.com with SMTP id sa20so96303veb.13 for ; Tue, 13 May 2014 02:38:42 -0700 (PDT) X-Received: by 10.58.154.10 with SMTP id vk10mr28207406veb.18.1399973922917; Tue, 13 May 2014 02:38:42 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp136730vcb; Tue, 13 May 2014 02:38:42 -0700 (PDT) X-Received: by 10.68.139.71 with SMTP id qw7mr3927622pbb.68.1399973921313; Tue, 13 May 2014 02:38:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rw8si12715492pab.167.2014.05.13.02.38.40; Tue, 13 May 2014 02:38:40 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760148AbaEMJib (ORCPT + 27 others); Tue, 13 May 2014 05:38:31 -0400 Received: from ip4-83-240-18-248.cust.nbox.cz ([83.240.18.248]:60909 "EHLO ip4-83-240-18-248.cust.nbox.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760111AbaEMJ25 (ORCPT ); Tue, 13 May 2014 05:28:57 -0400 Received: from ku by ip4-83-240-18-248.cust.nbox.cz with local (Exim 4.80.1) (envelope-from ) id 1Wk916-0002z2-8Y; Tue, 13 May 2014 11:28:56 +0200 From: Jiri Slaby To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Felipe Balbi , Jiri Slaby Subject: [PATCH 3.12 099/182] usb: musb: avoid NULL pointer dereference Date: Tue, 13 May 2014 11:27:31 +0200 Message-Id: <0ec874bf187165bfba2611ccc2d97d1543b0925c.1399973152.git.jslaby@suse.cz> X-Mailer: git-send-email 1.9.3 In-Reply-To: <7aa1bde8f6143b2db33e6567a8c3a4debaa246f4.1399973152.git.jslaby@suse.cz> References: <7aa1bde8f6143b2db33e6567a8c3a4debaa246f4.1399973152.git.jslaby@suse.cz> In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linux-kernel-owner@vger.kernel.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Felipe Balbi 3.12-stable review patch. If anyone has any objections, please let me know. =============== commit eee3f15d5f1f4f0c283dd4db67dc1b874a2852d1 upstream. instead of relying on the otg pointer, which can be NULL in certain cases, we can use the gadget and host pointers we already hold inside struct musb. Tested-by: Tony Lindgren Signed-off-by: Felipe Balbi Signed-off-by: Jiri Slaby --- drivers/usb/musb/musb_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index f7dca0b92bfb..2cca870d9762 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -439,7 +439,6 @@ void musb_hnp_stop(struct musb *musb) static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, u8 devctl) { - struct usb_otg *otg = musb->xceiv->otg; irqreturn_t handled = IRQ_NONE; dev_dbg(musb->controller, "<== DevCtl=%02x, int_usb=0x%x\n", devctl, @@ -654,7 +653,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, break; case OTG_STATE_B_PERIPHERAL: musb_g_suspend(musb); - musb->is_active = otg->gadget->b_hnp_enable; + musb->is_active = musb->g.b_hnp_enable; if (musb->is_active) { musb->xceiv->state = OTG_STATE_B_WAIT_ACON; dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n"); @@ -670,7 +669,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, break; case OTG_STATE_A_HOST: musb->xceiv->state = OTG_STATE_A_SUSPEND; - musb->is_active = otg->host->b_hnp_enable; + musb->is_active = musb->hcd->self.b_hnp_enable; break; case OTG_STATE_B_HOST: /* Transition to B_PERIPHERAL, see 6.8.2.6 p 44 */