From patchwork Thu Oct 30 10:30:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 5195461 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 63C779F349 for ; Thu, 30 Oct 2014 10:30:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9BC2C2024C for ; Thu, 30 Oct 2014 10:30:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B6B072025B for ; Thu, 30 Oct 2014 10:30:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758611AbaJ3Kag (ORCPT ); Thu, 30 Oct 2014 06:30:36 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:62467 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758808AbaJ3Kac (ORCPT ); Thu, 30 Oct 2014 06:30:32 -0400 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie1.idc.renesas.com with ESMTP; 30 Oct 2014 19:30:31 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 150DF4A863; Thu, 30 Oct 2014 19:30:31 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id F414C8002F; Thu, 30 Oct 2014 19:30:30 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id F38488002E; Thu, 30 Oct 2014 19:30:30 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac1.idc.renesas.com with ESMTP id VAL19802; Thu, 30 Oct 2014 19:30:30 +0900 X-IronPort-AV: E=Sophos;i="5.07,284,1413212400"; d="scan'208";a="173568560" Received: from mail-sg1lp0085.outbound.protection.outlook.com (HELO APAC01-SG1-obe.outbound.protection.outlook.com) ([207.46.51.85]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 30 Oct 2014 19:30:30 +0900 Received: from HKNPR06MB322.apcprd06.prod.outlook.com (10.141.38.16) by HKNPR06MB100.apcprd06.prod.outlook.com (10.242.102.152) with Microsoft SMTP Server (TLS) id 15.1.6.9; Thu, 30 Oct 2014 10:30:28 +0000 Received: from localhost (211.11.155.147) by HKNPR06MB322.apcprd06.prod.outlook.com (10.141.38.16) with Microsoft SMTP Server (TLS) id 15.1.11.14; Thu, 30 Oct 2014 10:30:27 +0000 From: Yoshihiro Shimoda To: , CC: , , Yoshihiro Shimoda , Subject: [PATCH v3 1/4] usb: renesas_usbhs: gadget: fix NULL pointer dereference in ep_disable() Date: Thu, 30 Oct 2014 19:30:16 +0900 Message-ID: <1414665019-1340-2-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1414665019-1340-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1414665019-1340-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: SIXPR06CA0051.apcprd06.prod.outlook.com (25.160.171.169) To HKNPR06MB322.apcprd06.prod.outlook.com (10.141.38.16) X-MS-Exchange-Transport-FromEntityHeader: Hosted X-Microsoft-Antispam: UriScan:;UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:HKNPR06MB322; X-Forefront-PRVS: 038002787A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(6069001)(199003)(189002)(85306004)(99396003)(120916001)(78352002)(80022003)(46102003)(48376002)(66066001)(64706001)(47776003)(20776003)(19580405001)(19580395003)(50466002)(95666004)(105586002)(97736003)(229853001)(107046002)(42382002)(31966008)(76482002)(106356001)(33646002)(36756003)(77156001)(21056001)(102836001)(40100003)(76506005)(50226001)(4396001)(76176999)(50986999)(104166001)(92726001)(92566001)(42186005)(93916002)(87286001)(88136002)(89996001)(101416001)(122386002)(77096002)(62966002)(85852003)(87976001)(88662002); DIR:OUT; SFP:1102; SCL:1; SRVR:HKNPR06MB322; H:localhost; FPR:; MLV:sfv; PTR:InfoNoRecords; A:0; MX:0; LANG:en; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:HKNPR06MB100; X-OriginatorOrg: renesas.com Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kazuya Mizuguchi This patch fixes an issue that the NULL pointer dereference happens when we uses g_audio driver. Since the g_audio driver will call usb_ep_disable() in afunc_set_alt() before it calls usb_ep_enable(), the uep->pipe of renesas usbhs driver will be NULL. So, this patch adds a condition to avoid the oops. Signed-off-by: Kazuya Mizuguchi Signed-off-by: Takeshi Kihara Signed-off-by: Yoshihiro Shimoda Cc: --- drivers/usb/renesas_usbhs/mod_gadget.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 2d17c10..2d0903f 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c @@ -602,6 +602,9 @@ static int usbhsg_ep_disable(struct usb_ep *ep) struct usbhsg_uep *uep = usbhsg_ep_to_uep(ep); struct usbhs_pipe *pipe = usbhsg_uep_to_pipe(uep); + if (!uep || !uep->pipe) + return -EINVAL; + usbhsg_pipe_disable(uep); usbhs_pipe_free(pipe);