From patchwork Fri Oct 31 01:24:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 5201201 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 78E83C11AC for ; Fri, 31 Oct 2014 01:24:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A3E7D201ED for ; Fri, 31 Oct 2014 01:24:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C4D9E201C7 for ; Fri, 31 Oct 2014 01:24:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161571AbaJaBYf (ORCPT ); Thu, 30 Oct 2014 21:24:35 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:61965 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1161369AbaJaBYe (ORCPT ); Thu, 30 Oct 2014 21:24:34 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie1.idc.renesas.com with ESMTP; 31 Oct 2014 10:24:32 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id E390F3A886; Fri, 31 Oct 2014 10:24:32 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id DB2CB1806F; Fri, 31 Oct 2014 10:24:32 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id D544F1800A; Fri, 31 Oct 2014 10:24:32 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac3.idc.renesas.com with ESMTP id LAH08141; Fri, 31 Oct 2014 10:24:32 +0900 X-IronPort-AV: E=Sophos;i="5.07,290,1413212400"; d="scan'208";a="173799971" Received: from mail-hk1lp0120.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.120]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 31 Oct 2014 10:24:32 +0900 Received: from localhost (211.11.155.147) by HKNPR06MB323.apcprd06.prod.outlook.com (10.141.38.17) with Microsoft SMTP Server (TLS) id 15.1.11.14; Fri, 31 Oct 2014 01:24:31 +0000 From: Yoshihiro Shimoda To: , CC: , , Yoshihiro Shimoda , Subject: [PATCH v4 1/4] usb: renesas_usbhs: gadget: fix NULL pointer dereference in ep_disable() Date: Fri, 31 Oct 2014 10:24:21 +0900 Message-ID: <1414718664-4568-2-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1414718664-4568-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1414718664-4568-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 X-Originating-IP: [211.11.155.147] X-ClientProxiedBy: HKXPR02CA0062.apcprd02.prod.outlook.com (25.161.48.47) To HKNPR06MB323.apcprd06.prod.outlook.com (10.141.38.17) X-MS-Exchange-Transport-FromEntityHeader: Hosted X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:HKNPR06MB323; X-Forefront-PRVS: 03818C953D X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(6069001)(199003)(189002)(92566001)(92726001)(99396003)(85852003)(64706001)(77096002)(78352002)(46102003)(122386002)(104166001)(80022003)(20776003)(19580405001)(97736003)(42186005)(93916002)(76506005)(19580395003)(89996001)(33646002)(47776003)(66066001)(87976001)(88136002)(76482002)(42382002)(87286001)(50466002)(48376002)(106356001)(107046002)(101416001)(229853001)(102836001)(120916001)(50986999)(105586002)(95666004)(21056001)(40100003)(85306004)(50226001)(76176999)(4396001)(77156001)(31966008)(36756003)(62966002)(88662002); DIR:OUT; SFP:1102; SCL:1; SRVR:HKNPR06MB323; 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..294d43c 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 (!pipe) + return -EINVAL; + usbhsg_pipe_disable(uep); usbhs_pipe_free(pipe);