From patchwork Fri Jun 14 11:21:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 251371 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 4A10B2C008F for ; Fri, 14 Jun 2013 21:21:27 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752352Ab3FNLV0 (ORCPT ); Fri, 14 Jun 2013 07:21:26 -0400 Received: from mail-bk0-f42.google.com ([209.85.214.42]:40752 "EHLO mail-bk0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752350Ab3FNLVZ (ORCPT ); Fri, 14 Jun 2013 07:21:25 -0400 Received: by mail-bk0-f42.google.com with SMTP id jk13so212085bkc.29 for ; Fri, 14 Jun 2013 04:21:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=MnWQxS0mQysXWgSx2XBfKas6Lxt+Asj3IrtlyUwH3kI=; b=YycWQwTbPjYZLNNPPDhKp2zPmdCOJs2s6TFi/50IRB8vnsG8T8rOHAEnkaNr+31Ndp qUzB3FvbTZwo6B8FIUKn4cA03tQFactdmScevyvxu0QN83v2pLo+E2SAK2oZagt91em/ q/POTZ65uTWmwbFGJPAuRWuOHT8GpO86mEViHQ/kO7GLjXjfhx6zFgZgIaajHbV7P1w9 o7msGf55CaM5FhdP3TbagYVyjUJX2oK6kmr3zGyrUUt16ZugR6Z0bxmLJUWFDR1G/lDG avnn8xzWDQUutBkCOIpEITlWuS399+m9Sz10excK03+ASxVPOlAM93vGL5i/Cfb1y9Ik W8HA== X-Received: by 10.204.224.135 with SMTP id io7mr283596bkb.46.1371208884326; Fri, 14 Jun 2013 04:21:24 -0700 (PDT) Received: from localhost (port-27034.pppoe.wtnet.de. [46.59.160.35]) by mx.google.com with ESMTPSA id oy6sm572999bkb.14.2013.06.14.04.21.22 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 14 Jun 2013 04:21:23 -0700 (PDT) From: Thierry Reding To: Greg Kroah-Hartman Cc: Alan Stern , Stephen Warren , linux-usb@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH] USB: EHCI: tegra: Fix oops in error cleanup Date: Fri, 14 Jun 2013 13:21:21 +0200 Message-Id: <1371208881-26916-1-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 1.8.2 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org Under some circumstances it happens that the connected PHY can't be powered up properly, in which case the cleanup path currently crashes because it checks the tegra->transceiver field using !IS_ERR(), which will succeed because it is in fact NULL. Dereferencing that pointer causes an oops in tegra_ehci_probe(). This patch fixes the issue by adding an additional label into the cleanup path to separately take down the PHY and the transceiver. Signed-off-by: Thierry Reding Reviewed-by: Stephen Warren Acked-by: Alan Stern --- Note: This is based on top of Stephen's latest patch series to allow building the driver as a module: [PATCH V3 REPOST 0/7] USB: tegra: support building as a module drivers/usb/host/ehci-tegra.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index 8dac5e4..6ee7ef7 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c @@ -478,15 +478,15 @@ static int tegra_ehci_probe(struct platform_device *pdev) err = usb_add_hcd(hcd, irq, IRQF_SHARED); if (err) { dev_err(&pdev->dev, "Failed to add USB HCD\n"); - goto cleanup_phy; + goto cleanup_transceiver; } return err; -cleanup_phy: +cleanup_transceiver: if (!IS_ERR(tegra->transceiver)) otg_set_host(tegra->transceiver->otg, NULL); - +cleanup_phy: usb_phy_shutdown(hcd->phy); cleanup_clk_en: clk_disable_unprepare(tegra->clk);