From patchwork Fri Jan 19 01:47:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13523280 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 69AB2C47422 for ; Fri, 19 Jan 2024 01:49:01 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:References: List-Owner; bh=KRB+3lpnuzXyitpPqKDfVL4Ga3xyFi8+fA0xW64MCDQ=; b=N9C46Iy9t20I/9 m6GhQty7dmBmvUBmfwf0jO2EzMa+/+WMZCRiE/ZXbsDR01A8iXuRaTokwqPjZ2Ii6C4F7JZuZ8d08 kIPG+56gHMhsow3TDLyLSOuimLyq+G4lRKm7JZ7A0sq1xFK0slZ5hedcXEPZfx+RrfGYQqkfe7Wn8 VPWu7oQGljjtALhvpOCHBzY864iyDLuFhm323A4eDT0WncHxFRgNPWxN51sq8eM0UxqYHtIU4XZJi p6JjcAxD79t3Mk0hJYwRMlTheHHB6y6e6mwuob2J40RCRq9IfV4h5b5EXzLOp9Y7LdJSdDSIiVRVd pC0b8j92wsuze6FF6tmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQdzh-004Ff1-30; Fri, 19 Jan 2024 01:48:29 +0000 Received: from phobos.denx.de ([85.214.62.61]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQdzb-004FeY-02 for linux-arm-kernel@lists.infradead.org; Fri, 19 Jan 2024 01:48:27 +0000 Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 3109487B6E; Fri, 19 Jan 2024 02:48:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1705628898; bh=N1Q8Iuceg6/qwWYYNFcIV0u3VsiiTwpxdHKO563CKTY=; h=From:To:Cc:Subject:Date:From; b=uKa8tNjfqOF5JAsloF1tNLrusJkXZskIdqOzQfDg2peYvnSDu5xnIMl3Ur4nH09cF Gtv5vT5kOYXgKz8xqMfUMMm8JMQcXG+K1fFZX0ZqJ1QP/2syNnb6OhQCCBr+Xpw0Qt LI150dVClYDFn/cU3Bx3HoedQuZYplnb+pZ2bzF+iI0+QZ1qK2xyfV2VjlMZkmqiy1 IpucqEbnDXiFM94p4vimvYoanAguk0aREHgRD6nWpQqW3fJXiR3KA9zSXXwQmyhh+r cofm3D+x9B/ZJSrpSKZfeSsZKBbyn/B7o/xyfwKJktBpNdLfpsod8wgMC9AVv5TGyc qItRDsQigvYPg== From: Marek Vasut To: linux-pm@vger.kernel.org Cc: Marek Vasut , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Fabio Estevam , Jindong Yue , Lucas Stach , Marco Felsch , NXP Linux Team , Peng Fan , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo , Ulf Hansson , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] pmdomain: imx8m-blk-ctrl: imx8mp-blk-ctrl: Error out if domains are missing in DT Date: Fri, 19 Jan 2024 02:47:41 +0100 Message-ID: <20240119014807.268694-1-marex@denx.de> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240118_174826_585742_FC80B5A6 X-CRM114-Status: GOOD ( 15.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This driver assumes that domain->power_dev is non-NULL in its suspend/resume path. The assumption is valid, since all the devices that are being looked up here should be described in DT. In case they are not described in DT, beause the DT is faulty, suspend/resume attempt would trigger NULL pointer dereference. To avoid this failure, check whether the power_dev assignment is not NULL right away in probe callback and fail early if it is. Signed-off-by: Marek Vasut Reviewed-by: Peng Fan --- Cc: "Uwe Kleine-König" Cc: Fabio Estevam Cc: Jindong Yue Cc: Lucas Stach Cc: Marco Felsch Cc: NXP Linux Team Cc: Peng Fan Cc: Pengutronix Kernel Team Cc: Sascha Hauer Cc: Shawn Guo Cc: Ulf Hansson Cc: linux-arm-kernel@lists.infradead.org Cc: linux-pm@vger.kernel.org --- V2: Add extra check for domain being NULL (thanks Peng) --- drivers/pmdomain/imx/imx8m-blk-ctrl.c | 9 ++++++--- drivers/pmdomain/imx/imx8mp-blk-ctrl.c | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c index 1341a707f61bc..ca942d7929c2b 100644 --- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c +++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c @@ -258,11 +258,14 @@ static int imx8m_blk_ctrl_probe(struct platform_device *pdev) domain->power_dev = dev_pm_domain_attach_by_name(dev, data->gpc_name); - if (IS_ERR(domain->power_dev)) { - dev_err_probe(dev, PTR_ERR(domain->power_dev), + if (IS_ERR_OR_NULL(domain->power_dev)) { + if (!domain->power_dev) + ret = -ENODEV; + else + ret = PTR_ERR(domain->power_dev); + dev_err_probe(dev, ret, "failed to attach power domain \"%s\"\n", data->gpc_name); - ret = PTR_ERR(domain->power_dev); goto cleanup_pds; } diff --git a/drivers/pmdomain/imx/imx8mp-blk-ctrl.c b/drivers/pmdomain/imx/imx8mp-blk-ctrl.c index e3203eb6a0229..e488cf79b8007 100644 --- a/drivers/pmdomain/imx/imx8mp-blk-ctrl.c +++ b/drivers/pmdomain/imx/imx8mp-blk-ctrl.c @@ -687,11 +687,14 @@ static int imx8mp_blk_ctrl_probe(struct platform_device *pdev) domain->power_dev = dev_pm_domain_attach_by_name(dev, data->gpc_name); - if (IS_ERR(domain->power_dev)) { - dev_err_probe(dev, PTR_ERR(domain->power_dev), + if (IS_ERR_OR_NULL(domain->power_dev)) { + if (!domain->power_dev) + ret = -ENODEV; + else + ret = PTR_ERR(domain->power_dev); + dev_err_probe(dev, ret, "failed to attach power domain %s\n", data->gpc_name); - ret = PTR_ERR(domain->power_dev); goto cleanup_pds; }