From patchwork Thu Feb 27 15:42:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 3734211 Return-Path: X-Original-To: patchwork-linux-arm@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 543A8BF13A for ; Thu, 27 Feb 2014 15:48:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 824F4201DD for ; Thu, 27 Feb 2014 15:48:32 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 80142201D3 for ; Thu, 27 Feb 2014 15:48:31 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJ3Bw-0008Sg-Mu; Thu, 27 Feb 2014 15:48:09 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJ36h-0001qt-4B; Thu, 27 Feb 2014 15:42:43 +0000 Received: from top.free-electrons.com ([176.31.233.9] helo=mail.free-electrons.com) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WJ36e-0001pr-68 for linux-arm-kernel@lists.infradead.org; Thu, 27 Feb 2014 15:42:41 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id 6DB7E81F; Thu, 27 Feb 2014 16:42:16 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost (128-79-216-6.hfc.dyn.abo.bbox.fr [128.79.216.6]) by mail.free-electrons.com (Postfix) with ESMTPSA id 235927E9; Thu, 27 Feb 2014 16:42:16 +0100 (CET) From: Alexandre Belloni To: Felipe Balbi Subject: [PATCH] usb: gadget: atmel_usba: fix crash when no endpoint are specified Date: Thu, 27 Feb 2014 16:42:13 +0100 Message-Id: <1393515733-15764-1-git-send-email-alexandre.belloni@free-electrons.com> X-Mailer: git-send-email 1.8.3.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140227_104240_330108_20AD695B X-CRM114-Status: UNSURE ( 9.84 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.2 (-) Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Nicolas Ferre , linux-kernel@vger.kernel.org, Alexandre Belloni , Gregory Clement , Maxime Ripard , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If no endpoints are present in the device tree, the kernel will cras hwith the following error: Unable to handle kernel paging request at virtual address 00101008 [...] [] (composite_dev_prepare) from [] (composite_bind+0x5c/0x190) [] (composite_bind) from [] (udc_bind_to_driver+0x48/0xf0) [] (udc_bind_to_driver) from [] (usb_gadget_probe_driver+0x7c/0xa0) [] (usb_gadget_probe_driver) from [] (do_one_initcall+0x94/0x140) [] (do_one_initcall) from [] (kernel_init_freeable+0xec/0x1b4) [] (kernel_init_freeable) from [] (kernel_init+0x8/0xe4) [] (kernel_init) from [] (ret_from_fork+0x14/0x24) Code: e5950014 e1a04001 e5902008 e3a010d0 (e5922008) ---[ end trace 35c74bdd89b373d0 ]--- Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b This checks for that case and returns an error, not allowing the driver to be loaded with no endpoints. Signed-off-by: Alexandre Belloni Acked-by: Nicolas Ferre --- drivers/usb/gadget/atmel_usba_udc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index 52771d4c44bc..e3e0c8ff242e 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c @@ -1914,6 +1914,12 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, i++; } + if (i == 0) { + dev_err(&pdev->dev, "of_probe: no endpoint specified\n"); + ret = -EINVAL; + goto err; + } + return eps; err: return ERR_PTR(ret);