From patchwork Mon Jan 25 12:01:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 60361 Delivered-To: patches@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp1306910lbb; Mon, 25 Jan 2016 04:02:04 -0800 (PST) X-Received: by 10.25.206.143 with SMTP id e137mr6240103lfg.97.1453723310825; Mon, 25 Jan 2016 04:01:50 -0800 (PST) Return-Path: Received: from mail-lb0-x231.google.com (mail-lb0-x231.google.com. [2a00:1450:4010:c04::231]) by mx.google.com with ESMTPS id jj10si9705271lbc.48.2016.01.25.04.01.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jan 2016 04:01:50 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c04::231 as permitted sender) client-ip=2a00:1450:4010:c04::231; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c04::231 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-lb0-x231.google.com with SMTP id x4so73356218lbm.0 for ; Mon, 25 Jan 2016 04:01:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Wl0q9ZNLV9cLSvvxSPCwXiiLiUTClsksN40EQDv53FM=; b=EbsmlUmjfgrS1sMGbZWnQB+xnUgg3RnxCX01tYXFCpj3ia7R74fHL0QIK92MEwkkt6 N+p0AthCBM/6WFF7T22t7CdO6ivwzSdMKHe803eyYr9YsL08dMYgwwdxtRHHU2olFj2E zkB1oSzYuyQHDiafRqnVejqQ7NMlnDvh+nrpU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Wl0q9ZNLV9cLSvvxSPCwXiiLiUTClsksN40EQDv53FM=; b=NVEMHswKgQ45D+Z44DMwYPKIUWcrUNLpZNMNqp2gv1dWpQ6UWjZOm5zZAfwosQjY8w +p/UJg7XOTZTdDKn0qYl0YIC7EAm7INGG8BCcZMznb12DgTJocbNLcK5KqyHcKHee5Kr YwXWl6XrAvh7TufW08fUKtiu2prUdXpf4Ci/vt3gH97TaUlbcRYF/0L8sUlP9jd9wge8 oDz+q1W+L96lutBvHbMuaiFbw2+uCe6YT16r8sZtU/bmTae2KmS2fh+TISRcX7UC/D27 ACBko38l5JpoaoJ/G3ZQmztgExxvRsQD1LOxmt90KzpK4Wg3qfAS8M7EP6JoHpckQ5/r +yHA== X-Gm-Message-State: AG10YORoXfpxwntLvmD0nkyGU9+twhv3GQrVVIWldLmsYCsy+LmSxcJbn/yakKLcNa+3YGcq4pw= X-Received: by 10.112.147.41 with SMTP id th9mr6223808lbb.74.1453723310592; Mon, 25 Jan 2016 04:01:50 -0800 (PST) Return-Path: Received: from uffe-Latitude-E6430s.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id o3sm2735785lfb.39.2016.01.25.04.01.49 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jan 2016 04:01:49 -0800 (PST) From: Ulf Hansson To: Felipe Balbi , linux-usb@vger.kernel.org Cc: Linus Walleij , Aaro Koskinen , Greg Kroah-Hartman , Ulf Hansson Subject: [PATCH] usb: musb: ux500: Fix NULL pointer dereference at system PM Date: Mon, 25 Jan 2016 13:01:29 +0100 Message-Id: <1453723289-23157-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 The commit 7d32cdef5356 ("usb: musb: fail with error when no DMA controller set"), caused the core platform driver to correctly return an error code when fail probing. Unfurtante it also caused bug for a NULL pointer dereference, during system suspend for the ux500 driver. The reason is a lacking validation of the corresponding ->driver_data pointer, which won't be set when the musb core driver fails to probe (or haven't yet been probed). Fixes: 7d32cdef5356 ("usb: musb: fail with error when no DMA...") Signed-off-by: Ulf Hansson --- drivers/usb/musb/ux500.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 1.9.1 Acked-by: Linus Walleij diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c index b2685e7..3eaa4ba 100644 --- a/drivers/usb/musb/ux500.c +++ b/drivers/usb/musb/ux500.c @@ -348,7 +348,9 @@ static int ux500_suspend(struct device *dev) struct ux500_glue *glue = dev_get_drvdata(dev); struct musb *musb = glue_to_musb(glue); - usb_phy_set_suspend(musb->xceiv, 1); + if (musb) + usb_phy_set_suspend(musb->xceiv, 1); + clk_disable_unprepare(glue->clk); return 0; @@ -366,7 +368,8 @@ static int ux500_resume(struct device *dev) return ret; } - usb_phy_set_suspend(musb->xceiv, 0); + if (musb) + usb_phy_set_suspend(musb->xceiv, 0); return 0; }