From patchwork Tue Jun 28 14:02:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 12898329 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 6353CC433EF for ; Tue, 28 Jun 2022 13:54:19 +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=TLpXLGl/CH7UQ3n0pgf8opSLiiinZR1FKbrxMvX14Vk=; b=dex/jPfbBS/cSs 4tmamrFLHYkq/BJD/2zUAgGUBl4N5ikS9V1TsMFMdp9eirjA4/8UjoIp/p8L0uM+DUxD+Oon9Exb9 KEyTMPtToF+Xgra6kWgEtN5KO10oIzXZez989wDi3P0clZ4eQSHhUlaey4KoILQYfL7Y8c+eTF4PP zVih0grHoDNtc40YASqbUxVcA1Kj2FrOvP2VYt4pIILyEgEj1bF39KjoDVAGtfEqiGlNj86CCvrZQ g1Y5X6KQMZXOfhHhGFNd8oqXjk+3K1hM42Ysaoft6774OnBzLyvE/D/6+DElrmMUSsvFKI+r6TVQm wgNVGXvN//tDm74DmhPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6Bea-006Y0i-0C; Tue, 28 Jun 2022 13:53:20 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6BeL-006Xrm-HY for linux-arm-kernel@lists.infradead.org; Tue, 28 Jun 2022 13:53:08 +0000 Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LXQwM1s9YzdZtk; Tue, 28 Jun 2022 21:50:43 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:52:58 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:52:58 +0800 From: Yang Yingliang To: , , CC: , , Subject: [PATCH -next 1/2] soc: fsl: guts: fix return value check in fsl_guts_init() Date: Tue, 28 Jun 2022 22:02:48 +0800 Message-ID: <20220628140249.1073809-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220628_065305_828887_44819B1F X-CRM114-Status: GOOD ( 11.65 ) 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 In case of error, of_iomap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test and return -ENOMEM as error value. Fixes: ab4988d6a393 ("soc: fsl: guts: embed fsl_guts_get_svr() in probe()") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang Reviewed-by: Michael Walle --- drivers/soc/fsl/guts.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c index 27035de062f8..8038c599ad83 100644 --- a/drivers/soc/fsl/guts.c +++ b/drivers/soc/fsl/guts.c @@ -195,9 +195,9 @@ static int __init fsl_guts_init(void) soc_data = match->data; regs = of_iomap(np, 0); - if (IS_ERR(regs)) { + if (!regs) { of_node_put(np); - return PTR_ERR(regs); + return -ENOMEM; } little_endian = of_property_read_bool(np, "little-endian"); From patchwork Tue Jun 28 14:02:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yingliang X-Patchwork-Id: 12898328 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 3C8C3C433EF for ; Tue, 28 Jun 2022 13:54:11 +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=YmaJ5IB7SpQAHsgkfolwkQiqyWfhrp4m9s+dhe5/AbQ=; b=kTi8HJfOAixCsY cQOThqFSAzcFWmP5Lxi2Pj9ipiVpu9K24EbwRMpOpeF6YMVKUAyujAqD6KVw9QPL/1kn4q7qXsGVU t2Tvg6nk63SwmR09NtNf2yULuey8h/n2SkjQ9a6uwMyHV/cJA+s0dCQBsAhAdToCPtzoA3mICG6ZC E+ITU0ovD9XwgizBcrAMoQj79fzCe4TfdhPleluz9eb0WEiOUi0MFAw+MwI/QeBrh5Y/MjfBG6jHI wkbyoeC8TkO/JXk23C+Do5p7I3jyo6hRly/YNhWlC4HKBRtpqwp7thEBzB9FzUdAZf+8cNc8h9H/g VfmTW0zFBpGq1uwMzm9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6BeO-006Xut-Je; Tue, 28 Jun 2022 13:53:08 +0000 Received: from szxga08-in.huawei.com ([45.249.212.255]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o6BeK-006Xrq-UX for linux-arm-kernel@lists.infradead.org; Tue, 28 Jun 2022 13:53:07 +0000 Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LXQwN0hKQz1L8k5; Tue, 28 Jun 2022 21:50:44 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:52:59 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 28 Jun 2022 21:52:58 +0800 From: Yang Yingliang To: , , CC: , , Subject: [PATCH -next 2/2] soc: fsl: guts: check return value after calling of_iomap() in fsl_guts_get_soc_uid() Date: Tue, 28 Jun 2022 22:02:49 +0800 Message-ID: <20220628140249.1073809-2-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220628140249.1073809-1-yangyingliang@huawei.com> References: <20220628140249.1073809-1-yangyingliang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220628_065305_223541_DF2C271B X-CRM114-Status: UNSURE ( 8.88 ) X-CRM114-Notice: Please train this message. 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 of_iomap() may return NULL, so we need check the return value. Fixes: 786dde1e59d7 ("soc: fsl: guts: add serial_number support") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang Reviewed-by: Michael Walle --- drivers/soc/fsl/guts.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c index 8038c599ad83..6bf3e6a980ff 100644 --- a/drivers/soc/fsl/guts.c +++ b/drivers/soc/fsl/guts.c @@ -126,6 +126,10 @@ static u64 fsl_guts_get_soc_uid(const char *compat, unsigned int offset) return 0; sfp_base = of_iomap(np, 0); + if (!sfp_base) { + of_node_put(np); + return 0; + } uid = ioread32(sfp_base + offset); uid <<= 32;