From patchwork Tue Jan 17 10:22:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ye.xingchen@zte.com.cn X-Patchwork-Id: 13104456 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 D919CC3DA78 for ; Tue, 17 Jan 2023 10:23:30 +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:Subject:Cc:To:From:Mime-Version: Message-ID:Date: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=ico85bTGSo4XgpSabkFj41uDtE+vk2nZv58Yb/xKo60=; b=z84 2veOgcl53YQGFi5SkYF8+DZETrbry/KJ6+0nOJHCjZNMIRez6zESA4ci9TllGCLeQWUF3lju12EzE Yl2yK9roJRdVG4owptSoLIWxifU9GtfD5Scu2kD9Ru1lBeztSrcWETFQlu8hEcXaBglsZE9lQ8xZu aQ+K1E0CrhlZfm5BFFwAzhwJV2pz8o7hRUW9x4jKeBH78WsAENRJ3wMG+Sd8fsrud0UCyxXgE9VHM 2tkNvmHYrX4W6OUMd+YGQzNuoUUE4jpeUeiq/UfVvUytVToNoPsfmKX0+hJ21P1k2a95xtb0v35TK tS5uqoxPJJ2hfuU5fih2volVAbBjZyw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHj6f-00DjSd-DC; Tue, 17 Jan 2023 10:22:17 +0000 Received: from mxhk.zte.com.cn ([63.216.63.35]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHj6b-00DjRC-RU for linux-arm-kernel@lists.infradead.org; Tue, 17 Jan 2023 10:22:15 +0000 Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4Nx4h023LVz6FK2P; Tue, 17 Jan 2023 18:22:08 +0800 (CST) Received: from xaxapp02.zte.com.cn ([10.88.97.241]) by mse-fl2.zte.com.cn with SMTP id 30HAM1uL018130; Tue, 17 Jan 2023 18:22:01 +0800 (+08) (envelope-from ye.xingchen@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid31; Tue, 17 Jan 2023 18:22:04 +0800 (CST) Date: Tue, 17 Jan 2023 18:22:04 +0800 (CST) X-Zmail-TransId: 2af963c676ccffffffffc36867c3 X-Mailer: Zmail v1.0 Message-ID: <202301171822040406304@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , Subject: =?utf-8?q?=5BPATCH=5D_ARM=3A_mvebu=3A_potential_dereference_of_null?= =?utf-8?q?_pointer?= X-MAIL: mse-fl2.zte.com.cn 30HAM1uL018130 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 63C676D0.000 by FangMail milter! X-FangMail-Envelope: 1673950928/4Nx4h023LVz6FK2P/63C676D0.000/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63C676D0.000/4Nx4h023LVz6FK2P X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230117_022214_081262_48B27EF3 X-CRM114-Status: UNSURE ( 9.91 ) 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 From: Minghao Chi The return value of kzalloc() needs to be checked. To avoid use of null pointer in case of the failure of alloc. Reported-by: Zeal Robot Signed-off-by: Minghao Chi Signed-off-by: ye xingchen --- arch/arm/mach-mvebu/board-v7.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c index fd5d0c8ff695..b93b4a8a8357 100644 --- a/arch/arm/mach-mvebu/board-v7.c +++ b/arch/arm/mach-mvebu/board-v7.c @@ -125,7 +125,8 @@ static void __init i2c_quirk(void) struct property *new_compat; new_compat = kzalloc(sizeof(*new_compat), GFP_KERNEL); - + if (!new_compat) + return; new_compat->name = kstrdup("compatible", GFP_KERNEL); new_compat->length = sizeof("marvell,mv78230-a0-i2c"); new_compat->value = kstrdup("marvell,mv78230-a0-i2c",