From patchwork Thu Dec 15 03:47:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13073887 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 C573BC00145 for ; Thu, 15 Dec 2022 03:49:24 +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=zkQwmig9JnnRx31/EP/xu/ZjlVcsjWMXif9pfChUoNs=; b=3gvW88PLhZh20z UFnNO8z/U932FRGElrI9986vZzNFgCa651RvurwSkwBMRJW0WDDeVlFk2ZOOTqrkCqT1a6CBs/MXX 8NpaVeQJl7IyZPdeJ6c7z8lRFZTO6j0t7baiKXsYNeODsqT7ChCCpwuEuSisj3P8w/oS2KFsNjDKJ PQ2Goo0KS4ErFBLRktrP0va6Cs/8m2Q73U8o2T0RQZcqDEkSZERQCsJJRJwNXXEgu61S7CyDiyTih Q+lDXYq9mYdGzlr+sXsu8e372+65Ge8Ffv/du/JNzvpvWYOYBVJfUYS1NfdJ1ye5EbXCXNr+C2y58 7Ta6CwSjHdQbvBc3NfuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p5fEM-0063VM-4F; Thu, 15 Dec 2022 03:48:22 +0000 Received: from phobos.denx.de ([2a01:238:438b:c500:173d:9f52:ddab:ee01]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p5fEI-0063RI-2W for linux-arm-kernel@lists.infradead.org; Thu, 15 Dec 2022 03:48:19 +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 7BCCD8431A; Thu, 15 Dec 2022 04:48:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1671076091; bh=j2ASRypmqla4U4zsz9E0rsIkEUbTONZGekA+TbtBMMI=; h=From:To:Cc:Subject:Date:From; b=pFTMLymklrKZ9laNgF8HzR6c2zrDKZd9gZn9G1robALzvHVeYOsBuRPvaMN6NZ679 bzb8kVB+qWJXC37lLyqM6w9hc/9jEZOhToiD3g6O1QIpSTbeERu/itrZSRrrdIzuP+ K5g7s+BQV0lvQMANRjDChgo3XpkrpvFCoNvryXRLICoXs9NSsEBJS/qkExd2ZGi0hn jzd/1ZDiMIJ5cVs3O5kcqoOFeIF1olgQ6/YuOND55q+6a0KBBpErmFvdW2GUp5qrJk I9Jcf7eucrK/ql81YOvdggHLeZHsDHR9xrTK4MqhfMEC2hzDezBk4+KNxBFYzjct+Q RUgC4YSlZyr0Q== From: Marek Vasut To: linux-arm-kernel@lists.infradead.org Cc: Marek Vasut , Adam Ford , Benjamin Gaignard , Fabio Estevam , Lucas Stach , Marco Felsch , NXP Linux Team , Paul Elder , Peng Fan , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo Subject: [PATCH 1/2] soc: imx: imx8m-blk-ctrl: Fix NULL pointer dereference Date: Thu, 15 Dec 2022 04:47:59 +0100 Message-Id: <20221215034800.275502-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221214_194818_368546_70EC2E8E X-CRM114-Status: GOOD ( 12.98 ) 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 Check domain->power_dev = dev_pm_domain_attach_by_name() return value using IS_ERR_OR_NULL() instead of plain IS_ERR(), and fail if domain->power_dev is either error or NULL. In case a power domain attached by dev_pm_domain_attach_by_name() is not described in DT, dev_pm_domain_attach_by_name() returns NULL, which is then used a few lines below in dev_set_name(domain->power_dev, ...);, which leads to NULL pointer dereference. Fixes: 2684ac05a8c4 ("soc: imx: add i.MX8M blk-ctrl driver") Signed-off-by: Marek Vasut --- Cc: Adam Ford Cc: Benjamin Gaignard Cc: Fabio Estevam Cc: Lucas Stach Cc: Marco Felsch Cc: Marek Vasut Cc: NXP Linux Team Cc: Paul Elder Cc: Peng Fan Cc: Pengutronix Kernel Team Cc: Sascha Hauer Cc: Shawn Guo To: linux-arm-kernel@lists.infradead.org --- drivers/soc/imx/imx8m-blk-ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/imx/imx8m-blk-ctrl.c b/drivers/soc/imx/imx8m-blk-ctrl.c index ddcf6be3d8b4a..2fbc8e6b2644b 100644 --- a/drivers/soc/imx/imx8m-blk-ctrl.c +++ b/drivers/soc/imx/imx8m-blk-ctrl.c @@ -256,7 +256,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); From patchwork Thu Dec 15 03:48:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13073888 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 C814EC4332F for ; Thu, 15 Dec 2022 03:49:28 +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:References:In-Reply-To: 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: List-Owner; bh=/NyARXMYEpUUiuP7YWFZgWW3vt48HWEiiTRSLz9mLtE=; b=ve/cmJvp5Jzf07 QXklpOuxJxXlK/rD0sx2gvGfTFGTx2vPCS4bRizxiGRfeKDNqPgpdDuLh3DC5XcDPQTml8fP4htZQ 8Ge2d4sX62FY3feLAXUyfDzE0LqhYu7+fnzLrI+DK4CxMtxdY1almOujln8gFTRUBGxQHq8hZKb56 UzTB5p1WP9TI0qZ2SVclHNMwWSk0T7pGyIdKVVocXwGVYPFerfBcRIjSZfkEXLA1Q+PmZaWP7Oy8k 4Zp6QCPe62etTC7XA0Eb6ktTOqAQaMZQoChdcIsBdnaEnuN7wzDVT0xmr73UGxMfc74uif+6fIx3U oJbAhjHATAm8zCRMs7xg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p5fEV-0063a5-Vv; Thu, 15 Dec 2022 03:48:32 +0000 Received: from phobos.denx.de ([2a01:238:438b:c500:173d:9f52:ddab:ee01]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p5fEI-0063RH-1j for linux-arm-kernel@lists.infradead.org; Thu, 15 Dec 2022 03:48:19 +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 074CE8530D; Thu, 15 Dec 2022 04:48:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1671076092; bh=MMjTqvzvaGwQV2xOyf/AmM65cSJutxkRPYJc1IciPLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eqd1RKpONSzKjSUfLLG3TZQbHB5wEv8aBQOX3xaCsc5ZFNj7fBiZljwno2YT2w7Nb 3abiG4iTJUUNaIKe2hyI+7eoDgSf1CTt+7b7k3XUbAxw66R7bm0AoC+Y2osqSEtgkG YQYsigAFcY17FOdhyvoEEkvxKrsIaLOjBT9qs5B3bqK0SzjM+8mdMyz6lyJBZWqd0V aHqv4LvqhyMMAmXGSoFJHThUjLZidsVs37WLkbvHLWRdKKCEqSC8ghYc6I1QGK0bIT pjzsvPnZtt3P5i2gWHn7LDFsKJ8Q0r+2V9XA4Zf4dDDuXs8P+dKvA/lYxi1o/Ds/TG tmcgOZFH8J3Nw== From: Marek Vasut To: linux-arm-kernel@lists.infradead.org Cc: Marek Vasut , Adam Ford , Benjamin Gaignard , Fabio Estevam , Lucas Stach , Marco Felsch , NXP Linux Team , Paul Elder , Peng Fan , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo Subject: [PATCH 2/2] soc: imx: imx8mp-blk-ctrl: Fix NULL pointer dereference Date: Thu, 15 Dec 2022 04:48:00 +0100 Message-Id: <20221215034800.275502-2-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221215034800.275502-1-marex@denx.de> References: <20221215034800.275502-1-marex@denx.de> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221214_194818_369644_3C6E8E6E X-CRM114-Status: GOOD ( 13.55 ) 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 Check domain->power_dev = dev_pm_domain_attach_by_name() return value using IS_ERR_OR_NULL() instead of plain IS_ERR(), and fail if domain->power_dev is either error or NULL. In case a power domain attached by dev_pm_domain_attach_by_name() is not described in DT, dev_pm_domain_attach_by_name() returns NULL, which is then used a few lines below in dev_set_name(domain->power_dev, ...);, which leads to NULL pointer dereference. Fixes: 556f5cf9568a ("soc: imx: add i.MX8MP HSIO blk-ctrl") Signed-off-by: Marek Vasut --- Cc: Adam Ford Cc: Benjamin Gaignard Cc: Fabio Estevam Cc: Lucas Stach Cc: Marco Felsch Cc: Marek Vasut Cc: NXP Linux Team Cc: Paul Elder Cc: Peng Fan Cc: Pengutronix Kernel Team Cc: Sascha Hauer Cc: Shawn Guo To: linux-arm-kernel@lists.infradead.org --- drivers/soc/imx/imx8mp-blk-ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/imx/imx8mp-blk-ctrl.c b/drivers/soc/imx/imx8mp-blk-ctrl.c index b7d4161fcda9c..916bf0b3bc975 100644 --- a/drivers/soc/imx/imx8mp-blk-ctrl.c +++ b/drivers/soc/imx/imx8mp-blk-ctrl.c @@ -553,7 +553,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);