Message ID | 1457577015-5364-2-git-send-email-yoshihiro.shimoda.uh@renesas.com (mailing list archive) |
---|---|
State | Accepted |
Delegated to: | Geert Uytterhoeven |
Headers | show
Return-Path: <linux-renesas-soc-owner@kernel.org> X-Original-To: patchwork-linux-renesas-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 907209F38C for <patchwork-linux-renesas-soc@patchwork.kernel.org>; Thu, 10 Mar 2016 02:30:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D8614202BE for <patchwork-linux-renesas-soc@patchwork.kernel.org>; Thu, 10 Mar 2016 02:30:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C5B620259 for <patchwork-linux-renesas-soc@patchwork.kernel.org>; Thu, 10 Mar 2016 02:30:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964868AbcCJCaj (ORCPT <rfc822;patchwork-linux-renesas-soc@patchwork.kernel.org>); Wed, 9 Mar 2016 21:30:39 -0500 Received: from relmlor1.renesas.com ([210.160.252.171]:16342 "EHLO relmlie4.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S964802AbcCJCag (ORCPT <rfc822;linux-renesas-soc@vger.kernel.org>); Wed, 9 Mar 2016 21:30:36 -0500 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie4.idc.renesas.com with ESMTP; 10 Mar 2016 11:30:34 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 7BAA93F44C; Thu, 10 Mar 2016 11:30:34 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id 6FCB58002E; Thu, 10 Mar 2016 11:30:34 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id 6A8CC8002D; Thu, 10 Mar 2016 11:30:34 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac1.idc.renesas.com with ESMTP id MAC23488; Thu, 10 Mar 2016 11:30:34 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="207344062" Received: from mail-hk2apc01lp0214.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.214]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 10 Mar 2016 11:30:33 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesasgroup-onmicrosoft-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=lEgsdDS1l3/1DZ1EbMdPv7CaeQ34MwhPTbULM+A+HQY=; b=uwBUeb1+maWQlLTRMTIzt8kABbRj5q2pxTfE3YIqYvJxwmq8P//ud2QgWHntGdKaQ1zl4zH9SrkK2TP9ZOxQfpbfQlMwW+cf3chlMecLYQ+Gy+NZlAhoW9d4rG8gVBzd7nNmpS0UZmny9OooDLn7D3y4bPrSlmbEgfGymTimRoQ= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=renesas.com; Received: from localhost (211.11.155.144) by SIXPR06MB0922.apcprd06.prod.outlook.com (10.162.173.157) with Microsoft SMTP Server (TLS) id 15.1.427.16; Thu, 10 Mar 2016 02:30:32 +0000 From: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> To: <balbi@kernel.org> CC: <gregkh@linuxfoundation.org>, <linux-usb@vger.kernel.org>, <linux-renesas-soc@vger.kernel.org>, <stable@vger.kernel.org>, Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Subject: [PATCH v2 1/2] usb: renesas_usbhs: avoid NULL pointer derefernce in usbhsf_pkt_handler() Date: Thu, 10 Mar 2016 11:30:14 +0900 Message-ID: <1457577015-5364-2-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 In-Reply-To: <1457577015-5364-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> References: <1457577015-5364-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR0201CA0021.apcprd02.prod.outlook.com (25.164.90.159) To SIXPR06MB0922.apcprd06.prod.outlook.com (25.162.173.157) X-MS-Office365-Filtering-Correlation-Id: 9013c463-9979-421d-c7c6-08d3488bf440 X-Microsoft-Exchange-Diagnostics: 1; SIXPR06MB0922; 2:hqAoZpulkzd2foKaU999EBmkUjE+/8PMj1ABbVWS/50Z8aVp8MaX9H8v5Ht24dG1teaHp9tv8tNE9lX5FeBewKiu/4N666DLEYVMvOf2uDPL9ou9aKAC+0V5EAlhscz7monUvuKUL905g9h1rGQh4UdmDeayU22f8WZx49trkUPWAkNdCjp3sYKTx0yu9nEg; 3:9Ap61rItOCDV/Ynrcp44qXckXB1z15nLCDvau9a0l4WnA6oPems5GKUiYs70deLCOyzKjaUJ98qEyW34sW+GF3baBLkFDPr2RrjDxgXIqcqBm4ocHRRMgIe1uSrTy7vI; 25:ykUQuukAwurY/GYdVBF26atoCGCIAo/IblN9qgHtye9/xn+Y8Mk7cJng/rn2NY1gkw6uVdFaQKt7D5qhabKif98dsV/IROkmdDAsoaGjdHpIKfbwMp/IqLqBEyVKNplIwicTzLwt6aMv/OQfViYIBee5iUYdzy7Ljr9MjKQbxBiHkN+o0k2s4ncSQcQhUMWnydMv3/YlT8nVrn0nWUoDODYzMmnZGtUD8pYPu8R+a3WuDmeS2Hh3Z61PcRvrJ2miuwoqNM8fqjzRBJ1xMrA9WaewHSbCYHukNvR3bMmqgXunV2Ts5wFilvDwj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8B40@SIXPR06MB0922.apcprd06.prod.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001); SRVR:SIXPR06MB0922; BCL:0; PCL:0; RULEID:; SRVR:SIXPR06MB0922; X-Forefront-PRVS: 08770259B4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(47776003)(92566002)(3846002)(6116002)(78352003)(1096002)(586003)(189998001)(48376002)(4001430100002)(5004730100002)(2906002)(50466002)(4326007)(110136002)(2950100001)(66066001)(36756003)(33646002)(19580405001)(19580395003)(50226001)(5008740100001)(77096005)(5003940100001)(2351001)(50986999)(229853001)(76176999)(42186005)(107886002)(42382002)(76506005)(81166005); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB0922; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SIXPR06MB0922; 23:Z7NG0MIEVd2CkRDTV2V8sSe1vdedVCrTUmVRo1j04?= =?us-ascii?Q?lbSGu9JQdb7wxAgCB/UjdptbPT+BqOmCy8LEPcVqnEV+rxhY4KSlR05jKczI?= =?us-ascii?Q?093mZRkv2+FcrXBYgrn1B2VsdawWsLG6HXycHAOFqgTTuallyiV8lNcYxLud?= =?us-ascii?Q?/0Oia9Ea07Bg24eeWD+FrHVikSHbwqlhoO6PsxgeQGwI2P3eCTfb7wA16LcV?= =?us-ascii?Q?P5D+YxePvhFI1gnTyky+4tuX8xAZYkqCD4EllUzdFDQMqX5CqmHruZQNrKo9?= =?us-ascii?Q?Awq8oYo6nmzqGEC0SCQi5DN7PEdURK3mXVjoRaYRySG1kw/FGYGGZzTcAfh0?= =?us-ascii?Q?Llvr9K0wLXth6Pcn+RptceKxEfY5qEosCuB296xCRNcZ0T3/SASv4r3Rs4SA?= =?us-ascii?Q?c4NjBZHTojVihOfGt5mc1Saf9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3jaELC2SDjnXCVyCYiq4fLuExKDzRPCiBmv52fp4RdKlIJUFrRVD2wT3/FdJhtew0W8WMPzeMGgCBAb9InNetSg9moJd+8oTn2spddGv0VdumKhD3E30sZZQE9CQb8NM= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2016 02:30:32.1943 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB0922 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: <linux-renesas-soc.vger.kernel.org> X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable 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 |
diff --git a/drivers/usb/renesas_usbhs/fifo.c b/drivers/usb/renesas_usbhs/fifo.c index b4de70e..0c25c01 100644 --- a/drivers/usb/renesas_usbhs/fifo.c +++ b/drivers/usb/renesas_usbhs/fifo.c @@ -190,7 +190,8 @@ static int usbhsf_pkt_handler(struct usbhs_pipe *pipe, int type) goto __usbhs_pkt_handler_end; } - ret = func(pkt, &is_done); + if (likely(func)) + ret = func(pkt, &is_done); if (is_done) __usbhsf_pkt_del(pkt);
When unexpected situation happened (e.g. tx/rx irq happened while DMAC is used), the usbhsf_pkt_handler() was possible to cause NULL pointer dereference like the followings: Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = c0004000 [00000000] *pgd=00000000 Internal error: Oops: 80000007 [#1] SMP ARM Modules linked in: usb_f_acm u_serial g_serial libcomposite CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.5.0-rc6-00842-gac57066-dirty #63 Hardware name: Generic R8A7790 (Flattened Device Tree) task: c0729c00 ti: c0724000 task.ti: c0724000 PC is at 0x0 LR is at usbhsf_pkt_handler+0xac/0x118 pc : [<00000000>] lr : [<c03257e0>] psr: 60000193 sp : c0725db8 ip : 00000000 fp : c0725df4 r10: 00000001 r9 : 00000193 r8 : ef3ccab4 r7 : ef3cca10 r6 : eea4586c r5 : 00000000 r4 : ef19ceb4 r3 : 00000000 r2 : 0000009c r1 : c0725dc4 r0 : ef19ceb4 This patch adds a condition to avoid the dereference. Fixes: e73a989 ("usb: renesas_usbhs: add DMAEngine support") Cc: <stable@vger.kernel.org> # v3.1+ Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> --- drivers/usb/renesas_usbhs/fifo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)