From patchwork Thu Jan 18 19:12:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13523109 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 9B80EC47DAF for ; Thu, 18 Jan 2024 19:13:32 +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=JvQG+Xoa9JPC0CIYPT39iFOuq1qEvX7pXswFC3qGyM8=; b=xoqcQsKl3IYSzQ vFaF2KBm5lluEDHM/ciQatUtfWSyEWIrcIJbKdMxTQkdmXhvZm3dXDd7O3q1nZVP3wGWPY2shuJT4 I86/r9RLaN2Dtz2y8ELGf561f0J4zWL5GMKyKNs4jLm3v1o/9O9cF3qti2zyExSvKwN98RcEkvvNC ixTEXH29Zf3K/sjDn8bgp08qrpLcbBdddl1yKXg+9x7FHCzztBVk+Q8wH4JWeuRfNlqoqwkkLceh+ WunHXeJqydn4FRiFStGxOy7I3vGGwcM7E9X2SuQ1yCcohEY3JOpl3Q3GzSeIGUIhhzIZLSSvEzN0p DaR+DkbfOs3gH1Chu0Hg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQXov-003aMf-2c; Thu, 18 Jan 2024 19:12:57 +0000 Received: from phobos.denx.de ([2a01:238:438b:c500:173d:9f52:ddab:ee01]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQXor-003aLn-34 for linux-arm-kernel@lists.infradead.org; Thu, 18 Jan 2024 19:12:55 +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 BDF5D85E44; Thu, 18 Jan 2024 20:12:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1705605171; bh=spLv23iepvexx7sMsCkjYR2XpICnNm57Tp/xysuWojw=; h=From:To:Cc:Subject:Date:From; b=PfFEVZQv57emsLHRD45ihb+DlgT0cWvBJTSX8IQx3FTvWOY7J4rkDcGIvMbwbx1ZW I6xw0uIGzpp8Ai6gFQo5F9XyAd0/g2T7s5u8Q16v16oUPoQ+vfMShL4lYnwP6xBjh7 f2r7U8FNYAMG/HPDi99aXn0LBsOhdbWlFkXiOHi9XP3FbLndyZi4U4zsJ7tPGLvFnb LO2fcgzFjrSDsx+fYSE17t3hPYBBszd3CLySsGgnplpzLzv7uhyUXHdzSsmYE0A5AJ uZWxGGooe7uYP6HE/4R1IdwfjefhsJhRyXC8FCjmJglf8EcQfw4Vh4fUlLPWDMVeau Q9ICPDeP2zcHw== 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] pmdomain: imx8m-blk-ctrl: imx8mp-blk-ctrl: Error out if domains are missing in DT Date: Thu, 18 Jan 2024 20:12:24 +0100 Message-ID: <20240118191235.145549-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_111254_331690_3E964657 X-CRM114-Status: GOOD ( 15.00 ) 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 --- 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 --- drivers/pmdomain/imx/imx8m-blk-ctrl.c | 2 +- drivers/pmdomain/imx/imx8mp-blk-ctrl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pmdomain/imx/imx8m-blk-ctrl.c b/drivers/pmdomain/imx/imx8m-blk-ctrl.c index 1341a707f61bc..1b83c9c2d5b77 100644 --- a/drivers/pmdomain/imx/imx8m-blk-ctrl.c +++ b/drivers/pmdomain/imx/imx8m-blk-ctrl.c @@ -258,7 +258,7 @@ 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)) { + if (IS_ERR_OR_NULL(domain->power_dev)) { dev_err_probe(dev, PTR_ERR(domain->power_dev), "failed to attach power domain \"%s\"\n", data->gpc_name); diff --git a/drivers/pmdomain/imx/imx8mp-blk-ctrl.c b/drivers/pmdomain/imx/imx8mp-blk-ctrl.c index e3203eb6a0229..3d6888afb416c 100644 --- a/drivers/pmdomain/imx/imx8mp-blk-ctrl.c +++ b/drivers/pmdomain/imx/imx8mp-blk-ctrl.c @@ -687,7 +687,7 @@ 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)) { + if (IS_ERR_OR_NULL(domain->power_dev)) { dev_err_probe(dev, PTR_ERR(domain->power_dev), "failed to attach power domain %s\n", data->gpc_name);