From patchwork Fri Jun 10 07:05:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alim Akhtar X-Patchwork-Id: 12876548 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 410A8C433EF for ; Fri, 10 Jun 2022 07:08:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=oRYhCSac9NwpZIP0E+njFOn2gvFRLgvdEQgcHuLnl8A=; b=xNB+XhKGZE/Uyc Pd4iSbA1jEHJnmXWl6E5/SekgQ/QR7K1KUEryj1BcibPBow/lelpKLbH3Uvlrve3RhjXzV2S5FCLU IkZtsYuHsDPO65Ido1ZmpomI7HN2V1hjiQL6NXX8/hKcxDzjHu9KdSwM5VjrzKSfY7S5xL0tyiV8F WJ6O5sZnOTQtL4D0OorEpfMt8IkEspL0D9al3AIF8ReOrnmdNWy0eScGZjjrLfN09M1o2YG4n+XX9 FfWnAOiopcv+VWaSM4ff6Vkdsm8aXl6tdj6ywKoAWJ5W+MdPzIYUmBoN3cBG7qEZJNiBMkkWdETJN N3eKoKYcihAT/ssPVUhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzYl4-006LIw-Lo; Fri, 10 Jun 2022 07:08:38 +0000 Received: from mailout4.samsung.com ([203.254.224.34]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzYko-006LBo-5O for linux-phy@lists.infradead.org; Fri, 10 Jun 2022 07:08:37 +0000 Received: from epcas5p4.samsung.com (unknown [182.195.41.42]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20220610070815epoutp04317ef7a4d9125c680c859bc68187bd60~3MKpDRDaV0178501785epoutp04c for ; Fri, 10 Jun 2022 07:08:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20220610070815epoutp04317ef7a4d9125c680c859bc68187bd60~3MKpDRDaV0178501785epoutp04c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1654844895; bh=hE7iC05RZWf8cGsOVWjbFzqwioyOOV6K8wR0RQ5vlLI=; h=From:To:Cc:Subject:Date:References:From; b=n2tGyuUyPmb0ZPXvJ2HXq7TApW0eaHqTjMGwBBNO2inoxrRoQ0Gmx2y/0Zhkh96qv xgCp7C2M6s076tgXYH0LSzhYiw+HH/dZhR1DsRVhA+X3RzpgOLYLWc9b0OUunwBOJm 5PKDF2Xrb8LmiBe6gEp2UwQx6F25hc4VvNGP+66U= Received: from epsnrtp1.localdomain (unknown [182.195.42.162]) by epcas5p4.samsung.com (KnoxPortal) with ESMTP id 20220610070815epcas5p475c7251b8e61e3f3c89dc12edc928610~3MKovvqBY0300703007epcas5p4D; Fri, 10 Jun 2022 07:08:15 +0000 (GMT) Received: from epsmges5p3new.samsung.com (unknown [182.195.38.177]) by epsnrtp1.localdomain (Postfix) with ESMTP id 4LKBrD1ByQz4x9Ps; Fri, 10 Jun 2022 07:08:12 +0000 (GMT) Received: from epcas5p1.samsung.com ( [182.195.41.39]) by epsmges5p3new.samsung.com (Symantec Messaging Gateway) with SMTP id 6E.EC.09762.BDDE2A26; Fri, 10 Jun 2022 16:08:12 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p3.samsung.com (KnoxPortal) with ESMTPA id 20220610070811epcas5p3c62ef9ad9c82092deac59ff9be896677~3MKlJaWKP2559525595epcas5p3S; Fri, 10 Jun 2022 07:08:11 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20220610070811epsmtrp20254b3377146c11187baf87f3c2e2b2a~3MKlImCGS0032200322epsmtrp2L; Fri, 10 Jun 2022 07:08:11 +0000 (GMT) X-AuditID: b6c32a4b-213ff70000002622-cf-62a2eddb6480 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 8C.DB.08924.BDDE2A26; Fri, 10 Jun 2022 16:08:11 +0900 (KST) Received: from Jaguar.sa.corp.samsungelectronics.net (unknown [107.108.73.139]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220610070810epsmtip290a240d007d93f0c38a07a18332ccd4d~3MKjyNClE1143511435epsmtip2h; Fri, 10 Jun 2022 07:08:10 +0000 (GMT) From: Alim Akhtar To: linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org Cc: krzysztof.kozlowski+dt@linaro.org, vkoul@kernel.org, chanho61.park@samsung.com, pankaj.dubey@samsung.com, Alim Akhtar Subject: [PATCH -next] phy: samsung-ufs: fix NULL pointer dereference Date: Fri, 10 Jun 2022 12:35:47 +0530 Message-Id: <20220610070547.71193-1-alim.akhtar@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrIKsWRmVeSWpSXmKPExsWy7bCmuu6dt4uSDHr3Mlk8mLeNzeLyfm2L vhcPmS0u75rDZjFh1TcWi0Vbv7Bb7LxzgtmB3WPTqk42jzvX9rB5bF5S79G3ZRWjx+dNcgGs Udk2GamJKalFCql5yfkpmXnptkrewfHO8aZmBoa6h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mKPExsWy7bCSvO7tt4uSDN4vVrZ4MG8bm8Xl/doW fS8eMltc3jWHzWLCqm8sFou2fmG32HnnBLMDu8emVZ1sHneu7WHz2Lyk3qNvyypGj8+b5AJY o7hsUlJzMstSi/TtErgyzpx4zFgwUaTi58ulLA2MqwW7GDk4JARMJBZOKe9i5OIQEtjBKHF7 1nHmLkZOoLi0xPWNE9ghbGGJlf+es0MUNTFJ7HmxFqyITUBb4u70LUwgtoiAo8SX/z9ZQIqY BWYzSqxpWcMGkhAWcJU4smcu2CQWAVWJjStfgtm8AjYSf9Y8YoLYIC+xesMB5gmMPAsYGVYx SqYWFOem5xYbFhjlpZbrFSfmFpfmpesl5+duYgSHkJbWDsY9qz7oHWJk4mA8xCjBwawkwhtw e1GSEG9KYmVValF+fFFpTmrxIUZpDhYlcd4LXSfjhQTSE0tSs1NTC1KLYLJMHJxSDUxbJbQk ZqRY/Fj8c2GlhvcrnVPZjPKhR9bvPP2rsuX4tILt8cGsqRHRfv97trI3ikY9/VvYpGJ+bm77 Ne7MXYvkupyC3bnmG3++eOtYLcuHOBeTiZzsyh+5y56VL/G5cN1v7n8jTRZ5vrBuv4qpm8Mm K3LsODTl/zsTGf6kL8derPGIuh0jZ994f9tVhalzpvHL1exdL1VoLnb41zXe4mezZr9YVWFn n7H1e/PErqTyj6+X7rZW2VJz62utkP1V1qeLtqcwbYtmbj//d7JY+4ePeufir0SvnLCgv39l bpzdr0KxU5LaFspyLIkn1d7yX3zSeJ1V9mdWWPybk3ENoioTuK1Uz0nt3yLv4X88TUyJpTgj 0VCLuag4EQBR0E+qkAIAAA== X-CMS-MailID: 20220610070811epcas5p3c62ef9ad9c82092deac59ff9be896677 X-Msg-Generator: CA CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220610070811epcas5p3c62ef9ad9c82092deac59ff9be896677 References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220610_000826_824094_9704B0DF X-CRM114-Status: GOOD ( 15.10 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org commit f86c1d0a58b1f63a ("phy: samsung: ufs: remove drvdata from struct samsung_ufs_phy") removes _drvdata_ initialization which resulting in NULL pointer dereferencing in samsung_ufs_phy_wait_for_lock_acq(). Fix this by initializing drvdata. The said commit also duplicate "has_symbol_clk" both in drvdata struct and in samsung_ufs_phy struct, let's go back and use only one "has_symbol_clk". Fixes: f86c1d0a58b1 phy: samsung: ufs: remove drvdata from struct samsung_ufs_phy Signed-off-by: Alim Akhtar --- drivers/phy/samsung/phy-samsung-ufs.c | 6 +++--- drivers/phy/samsung/phy-samsung-ufs.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) base-commit: ff539ac73ea559a8c146d99ab14bfcaddd30547a diff --git a/drivers/phy/samsung/phy-samsung-ufs.c b/drivers/phy/samsung/phy-samsung-ufs.c index 206a79c69a6c..6708877b20d7 100644 --- a/drivers/phy/samsung/phy-samsung-ufs.c +++ b/drivers/phy/samsung/phy-samsung-ufs.c @@ -207,7 +207,7 @@ static int samsung_ufs_phy_init(struct phy *phy) ss_phy->lane_cnt = phy->attrs.bus_width; ss_phy->ufs_phy_state = CFG_PRE_INIT; - if (ss_phy->has_symbol_clk) { + if (ss_phy->drvdata->has_symbol_clk) { ret = samsung_ufs_phy_symbol_clk_init(ss_phy); if (ret) dev_err(ss_phy->dev, "failed to set ufs phy symbol clocks\n"); @@ -259,7 +259,7 @@ static int samsung_ufs_phy_exit(struct phy *phy) clk_disable_unprepare(ss_phy->ref_clk); - if (ss_phy->has_symbol_clk) { + if (ss_phy->drvdata->has_symbol_clk) { clk_disable_unprepare(ss_phy->tx0_symbol_clk); clk_disable_unprepare(ss_phy->rx0_symbol_clk); clk_disable_unprepare(ss_phy->rx1_symbol_clk); @@ -327,8 +327,8 @@ static int samsung_ufs_phy_probe(struct platform_device *pdev) drvdata = match->data; phy->dev = dev; + phy->drvdata = drvdata; phy->cfgs = drvdata->cfgs; - phy->has_symbol_clk = drvdata->has_symbol_clk; memcpy(&phy->isol, &drvdata->isol, sizeof(phy->isol)); if (!of_property_read_u32_index(dev->of_node, "samsung,pmu-syscon", 1, diff --git a/drivers/phy/samsung/phy-samsung-ufs.h b/drivers/phy/samsung/phy-samsung-ufs.h index 854b53bdf347..b9144586daf5 100644 --- a/drivers/phy/samsung/phy-samsung-ufs.h +++ b/drivers/phy/samsung/phy-samsung-ufs.h @@ -125,7 +125,6 @@ struct samsung_ufs_phy { const struct samsung_ufs_phy_drvdata *drvdata; const struct samsung_ufs_phy_cfg * const *cfgs; struct samsung_ufs_phy_pmu_isol isol; - bool has_symbol_clk; u8 lane_cnt; int ufs_phy_state; enum phy_mode mode;