From patchwork Tue May 26 20:29:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 11571201 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9BCFC60D for ; Tue, 26 May 2020 20:30:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81B09208A7 for ; Tue, 26 May 2020 20:30:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="DvdWnLIS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391244AbgEZUaQ (ORCPT ); Tue, 26 May 2020 16:30:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389853AbgEZUaJ (ORCPT ); Tue, 26 May 2020 16:30:09 -0400 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A6BBC03E96D; Tue, 26 May 2020 13:30:09 -0700 (PDT) Received: by mail-ed1-x544.google.com with SMTP id b91so18798082edf.3; Tue, 26 May 2020 13:30:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qJGAhXW9kaqHmdjOkBKCCdqPZdpTsmEr75Eb52L7QxM=; b=DvdWnLISXQXckcKGz5k9iHMnMLw7t+1Bf5ROTwcPt0G7qtxsWYK0OLFt/tU4vxx5HS p9EtwrWaJYBdUO6wX0O+ud7L5aW0BxMpMbjSSzaTcR42410tsoOJDstMiRFCexUxy7ub 4sEe/Q5IELF9Hj3JKo85j6fTjE2mt+OINcfHZ7ALe+tA9B/K0rb7zr6tvZpj18bOe0VK bih/T7ZuWH3bpXLMP93jHxz/4p0S4r6KYn+iYt2V/QgkJrHgdLNqHkgYlbvMl7UBO6DW Uo3H+PhKLoc4hnnghNVyaGDunmyCoqxaFV+7xL9yD+zzN7TIBT/ErUdSC0OjLzed6nYp Le3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qJGAhXW9kaqHmdjOkBKCCdqPZdpTsmEr75Eb52L7QxM=; b=g2MRwGY7lICjxo5i4wY67HuUMfE59bBgoluVZV66hzn/Xf2LeMhtTi91zbRWu7iC2k KjMoJST/5VKHRSkc+D/Gi66LMeDwV7m42L2757SRxO3X7XTjdA5M0L+E7lvL8UZEn6Ke aqFbebIRylUiIq7goZEfHAJNE/WHrpbBY+7AiIs09xcesRKn6zpfakrRHpWQ6/6vxbcS LsgA6Gkq3mf3wn+DuRkXK7icT8Z7l03gg1WGU4tIS5sz2LAcS1kG5BbTkNLE8SSn+dPe blS5jnEYrV7MsFu3YLG2UqkO1pSt+qCoZlTjK7u+VZsSp4OESQCxBkM7K80H0Vv/k+zz uTtg== X-Gm-Message-State: AOAM532ccLxu58N45L3PY9Bx4VchY0/MMkGz7YVIq1a4dK7V5WaTcei2 2b1AyEOP9TBN1iQevVc5Qy0= X-Google-Smtp-Source: ABdhPJy0Ce3NFppUwfK2zdiMLWn+r3b9wC6i+sHOfqsQ0eHIH0E7/7C4q8MKdRlIaLKasDmDQnql+w== X-Received: by 2002:a05:6402:8c1:: with SMTP id d1mr21864323edz.265.1590525008143; Tue, 26 May 2020 13:30:08 -0700 (PDT) Received: from localhost.localdomain (p200300f137189200428d5cfffeb99db8.dip0.t-ipconnect.de. [2003:f1:3718:9200:428d:5cff:feb9:9db8]) by smtp.googlemail.com with ESMTPSA id ce16sm735517ejb.76.2020.05.26.13.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 13:30:07 -0700 (PDT) From: Martin Blumenstingl To: balbi@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-amlogic@lists.infradead.org, narmstrong@baylibre.com Cc: hanjie.lin@amlogic.com, yue.wang@amlogic.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Blumenstingl Subject: [PATCH for-5.8 1/2] usb: dwc3: meson-g12a: fix error path when fetching the reset line fails Date: Tue, 26 May 2020 22:29:42 +0200 Message-Id: <20200526202943.715220-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526202943.715220-1-martin.blumenstingl@googlemail.com> References: <20200526202943.715220-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Disable and unprepare the clocks when devm_reset_control_get_shared() fails. This fixes the error path as this must disable the clocks which were previously enabled. Fixes: 1e355f21d3fb96 ("usb: dwc3: Add Amlogic A1 DWC3 glue") Cc: Yue Wang Cc: Hanjie Lin Signed-off-by: Martin Blumenstingl Acked-by: Neil Armstrong --- drivers/usb/dwc3/dwc3-meson-g12a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c index bd744e82cad4..ce5388338389 100644 --- a/drivers/usb/dwc3/dwc3-meson-g12a.c +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c @@ -738,7 +738,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) if (IS_ERR(priv->reset)) { ret = PTR_ERR(priv->reset); dev_err(dev, "failed to get device reset, err=%d\n", ret); - return ret; + goto err_disable_clks; } ret = reset_control_reset(priv->reset); From patchwork Tue May 26 20:29:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 11571199 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EA489159A for ; Tue, 26 May 2020 20:30:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D2D39208A7 for ; Tue, 26 May 2020 20:30:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=googlemail.com header.i=@googlemail.com header.b="jXqpT17h" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391231AbgEZUaN (ORCPT ); Tue, 26 May 2020 16:30:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389367AbgEZUaM (ORCPT ); Tue, 26 May 2020 16:30:12 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1070C061A0F; Tue, 26 May 2020 13:30:10 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id h21so25267862ejq.5; Tue, 26 May 2020 13:30:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+HLyQeHEwRkmBN7Mz1fWdkXpoemib6Ct8xH1uqDFVgM=; b=jXqpT17hC9igpJGL8HqGKNSS1UpVOL7bro0lhrsTvwHSTf3+2sZmgHAZq3AmMUN1u4 qmFWaqtO5r5SV/aJJGR7/gy/iFe3UC1WIkMs/RVrQtoHON7mQ81GTCHXFax3O1QnW8e4 SsLD/tkyohqFtjaLi7YLYiqi3eq0y7ZCtPWuY0S0xMWuH4oF/EMAWtIJdgYvFx4x9g4P AMQGTDivXwDTtuctM3ElwNCTec3EHAb9u2PA8KUWGMC8i5HmPwR5VxsktsrLlZSRtD6H mO+B/1E5RbIv/5q2xI4e5ROZOCsZY/1nyzUZtts/2X4titAry4ZX5yFDy2AWNPlSxaie vfmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+HLyQeHEwRkmBN7Mz1fWdkXpoemib6Ct8xH1uqDFVgM=; b=HzahqeuM/5oOeNICFhbJ3D5GpauYfCS+y3SzhcoChM39CC2o6cs8esNg3Ovt5Pjg8U T6jqAoGS5tCHhw/IV7En5Ldw0sOwdwQ1DVWH+A89vToFWIxROMBp53rmIkfB0M7zi0RC JbEOQouuH0PlmaSJO62J0YmOy6PFk1YRgrjDih9PJJoFBVRrW+y2J+DOIMQq9VD0roMA dLiFkiITq1Sk6fYu5Jb0RxqVMQFtjNVd58tYLgyp+bMhnffztP5JFjg6Jyo1D/9nj9cw WjXc8iYHRErsIgscMZmgN9wSschQaDuF10OaeUBT6YnmPqelCQzz3YSI+Xf0EPqfhqEq dKLg== X-Gm-Message-State: AOAM532SRkwexiRDULhg3mNlxxdR5TCjo/O9XPNc9NPKhr/gEwNkH0VU wndP5dFVAVOLHafNgJMsR1k= X-Google-Smtp-Source: ABdhPJxqtvm6ZozNr3OfWjYHXrv9+mhZTQjYNNza+YL7N1NIhEwIs64tPCmgerGMOLsrKUYhFRDdAw== X-Received: by 2002:a17:906:4815:: with SMTP id w21mr2784486ejq.533.1590525009201; Tue, 26 May 2020 13:30:09 -0700 (PDT) Received: from localhost.localdomain (p200300f137189200428d5cfffeb99db8.dip0.t-ipconnect.de. [2003:f1:3718:9200:428d:5cff:feb9:9db8]) by smtp.googlemail.com with ESMTPSA id ce16sm735517ejb.76.2020.05.26.13.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 13:30:08 -0700 (PDT) From: Martin Blumenstingl To: balbi@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-amlogic@lists.infradead.org, narmstrong@baylibre.com Cc: hanjie.lin@amlogic.com, yue.wang@amlogic.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Martin Blumenstingl , "kernelci.org bot" Subject: [PATCH for-5.8 2/2] usb: dwc3: meson-g12a: fix USB2 PHY initialization on G12A and A1 SoCs Date: Tue, 26 May 2020 22:29:43 +0200 Message-Id: <20200526202943.715220-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526202943.715220-1-martin.blumenstingl@googlemail.com> References: <20200526202943.715220-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org dwc3_meson_g12a_usb2_init_phy() crashes with NULL pointer on an SM1 board (which uses the same USB setup as G12A) dereference as reported by the Kernel CI bot. This is because of the following call flow: dwc3_meson_g12a_probe priv->drvdata->setup_regmaps dwc3_meson_g12a_setup_regmaps priv->usb2_ports is still 0 so priv->u2p_regmap[i] will be NULL dwc3_meson_g12a_get_phys initializes priv->usb2_ports priv->drvdata->usb_init dwc3_meson_g12a_usb_init dwc3_meson_g12a_usb_init_glue dwc3_meson_g12a_usb2_init priv->drvdata->usb2_init_phy dwc3_meson_g12a_usb2_init_phy dereferences priv->u2p_regmap[i] Call priv->drvdata->setup_regmaps only after dwc3_meson_g12a_get_phys so priv->usb2_ports is initialized and the regmaps will be set up correctly. This fixes the NULL dereference later on. Fixes: 013af227f58a97 ("usb: dwc3: meson-g12a: handle the phy and glue registers separately") Reported-by: "kernelci.org bot" Signed-off-by: Martin Blumenstingl Acked-by: Neil Armstrong Acked-by: Felipe Balbi --- drivers/usb/dwc3/dwc3-meson-g12a.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c index ce5388338389..1f7f4d88ed9d 100644 --- a/drivers/usb/dwc3/dwc3-meson-g12a.c +++ b/drivers/usb/dwc3/dwc3-meson-g12a.c @@ -708,11 +708,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) return PTR_ERR(base); priv->drvdata = of_device_get_match_data(&pdev->dev); - priv->dev = dev; - ret = priv->drvdata->setup_regmaps(priv, base); - if (ret) - return ret; priv->vbus = devm_regulator_get_optional(dev, "vbus"); if (IS_ERR(priv->vbus)) { @@ -749,6 +745,10 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) if (ret) goto err_disable_clks; + ret = priv->drvdata->setup_regmaps(priv, base); + if (ret) + return ret; + if (priv->vbus) { ret = regulator_enable(priv->vbus); if (ret)