From patchwork Thu Oct 30 04:02:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 5193361 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4705AC11AC for ; Thu, 30 Oct 2014 04:03:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 99780201CD for ; Thu, 30 Oct 2014 04:03:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1283E20254 for ; Thu, 30 Oct 2014 04:03:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751212AbaJ3EDA (ORCPT ); Thu, 30 Oct 2014 00:03:00 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:41762 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751124AbaJ3EC7 (ORCPT ); Thu, 30 Oct 2014 00:02:59 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie2.idc.renesas.com with ESMTP; 30 Oct 2014 13:02:57 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 9634D43693; Thu, 30 Oct 2014 13:02:57 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 8F9561806F; Thu, 30 Oct 2014 13:02:57 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 8B6AE1800A; Thu, 30 Oct 2014 13:02:57 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac3.idc.renesas.com with ESMTP id PBD02325; Thu, 30 Oct 2014 13:02:57 +0900 X-IronPort-AV: E=Sophos;i="5.07,282,1413212400"; d="scan'208";a="172409169" Received: from mail-hk1lp0119.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.119]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 30 Oct 2014 13:02:56 +0900 Received: from localhost (211.11.155.147) by SINPR06MB329.apcprd06.prod.outlook.com (10.141.110.15) with Microsoft SMTP Server (TLS) id 15.1.6.9; Thu, 30 Oct 2014 04:02:55 +0000 From: Yoshihiro Shimoda To: , CC: , , Yoshihiro Shimoda , Subject: [PATCH v2 1/4] usb: renesas_usbhs: gadget: fix NULL pointer dereference in ep_disable() Date: Thu, 30 Oct 2014 13:02:44 +0900 Message-ID: <1414641767-5780-2-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1414641767-5780-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1414641767-5780-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: SG2PR03CA0005.apcprd03.prod.outlook.com (25.160.233.15) To SINPR06MB329.apcprd06.prod.outlook.com (10.141.110.15) X-MS-Exchange-Transport-FromEntityHeader: Hosted X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:SINPR06MB329; X-Forefront-PRVS: 038002787A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6069001)(6009001)(199003)(189002)(87286001)(87976001)(50226001)(85852003)(92566001)(33646002)(93916002)(42382002)(76482002)(36756003)(122386002)(19580395003)(99396003)(120916001)(19580405001)(4396001)(50466002)(102836001)(64706001)(20776003)(47776003)(62966002)(77096002)(97736003)(48376002)(101416001)(50986999)(77156001)(76506005)(76176999)(66066001)(92726001)(85306004)(42186005)(104166001)(80022003)(46102003)(40100003)(105586002)(21056001)(31966008)(95666004)(106356001)(229853001)(107046002)(78352002)(89996001)(88662002); DIR:OUT; SFP:1102; SCL:1; SRVR:SINPR06MB329; H:localhost; FPR:; MLV:sfv; PTR:InfoNoRecords; A:0; MX:0; LANG:en; 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);