From patchwork Thu Jan 19 02:51:18 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: 45568 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp112619wrn; Wed, 18 Jan 2023 19:12:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXuHNC/UDtIjcboveOSSsauKDgU/LS4YJyjtO3LDMh8+dStqUrzBF/mD5MjHQzN8Gu5LAtye X-Received: by 2002:a17:907:a80b:b0:86f:220e:94af with SMTP id vo11-20020a170907a80b00b0086f220e94afmr19617359ejc.56.1674097950095; Wed, 18 Jan 2023 19:12:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674097950; cv=none; d=google.com; s=arc-20160816; b=coFFDszRnxMvwA3CXlnl5c2lgfjFO1LzLd3EsFQ0bzGsk+ofssbYXa9zBTFi94zM7N o/F3F2hoRsUgibKnZ+kPAqf5zPsvS8Y+bggvx7IzOKVndBn33SlWokx8ITp8tDxHulma /zR1L9mlSsU1m881GI0DG5NpNjnO2GQPP+kWeA4UupFiXly/I9sFfBF24Nyfxgqt8uno KbLrA4LW08lrkzGEKE5nUiDcd3U1/2aQ0X6Z7eoouOOUXtl+nfJickFIldf14zLhjsmo AodUmQt0zSZL8rfZ0YWIS6DU0/2b/3fYBxw3L6oQwaqiDeRccFqSWYtNv0u2W5KKYKCx ofqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=C0SJCn1yCbMpJ9ppbGqYjIG/l8WQ+P/EYR5n9dCBCOY=; b=Bx3U2A3kvN+dbZ5i89Iqk8aDl9rI8eVBgmZ9IIZ0BlyVxyognI2PJsz/nBCYfxF/a8 CQH+DuFDTZ94MBzsjL3ZejvpUJZVkuzgWccIL/NecqABLib3L/IxBY5e8q7NxoAq117f Nlvkgk7tcyfNBAazsDDcuAswsEwjPJWHs2HwY/MVXCjZ+76O2zOuqDcLDX8Zzn4NFWHn 4hnGBSOjRFfgCF+3bQpRq/Kz5wQdQRdOxB+LSkcS13oEz9vOJ9U9D3k1tuR9DwVcMJNp CtwNFi9DSARl2jwuKQnLw/J1qL4IXScLlNopQjcmy0XbNEgs2D5pOOe7rGSEe56o4vPv r4rw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020a1709065d1000b00872c15a159csi3531478ejt.263.2023.01.18.19.12.05; Wed, 18 Jan 2023 19:12:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230003AbjASCva (ORCPT + 99 others); Wed, 18 Jan 2023 21:51:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229838AbjASCv2 (ORCPT ); Wed, 18 Jan 2023 21:51:28 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3FF8689C0 for ; Wed, 18 Jan 2023 18:51:25 -0800 (PST) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxct.zte.com.cn (FangMail) with ESMTPS id 4Ny6b02HyDz501RM; Thu, 19 Jan 2023 10:51:24 +0800 (CST) Received: from xaxapp02.zte.com.cn ([10.88.97.241]) by mse-fl1.zte.com.cn with SMTP id 30J2pHJo048709; Thu, 19 Jan 2023 10:51:17 +0800 (+08) (envelope-from ye.xingchen@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid31; Thu, 19 Jan 2023 10:51:18 +0800 (CST) Date: Thu, 19 Jan 2023 10:51:18 +0800 (CST) X-Zmail-TransId: 2af963c8b026ffffffffd66c3ac3 X-Mailer: Zmail v1.0 Message-ID: <202301191051184033370@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-fl1.zte.com.cn 30J2pHJo048709 X-Fangmail-Gw-Spam-Type: 0 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63C8B02C.000/4Ny6b02HyDz501RM X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, T_SPF_PERMERROR,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755418931991777180?= X-GMAIL-MSGID: =?utf-8?q?1755418931991777180?= 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 Reviewed-by: Andrew Lunn --- arch/arm/mach-mvebu/board-v7.c | 4 ++++ arch/arm/mach-mvebu/coherency.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c index fd5d0c8ff695..3c031b2efe16 100644 --- a/arch/arm/mach-mvebu/board-v7.c +++ b/arch/arm/mach-mvebu/board-v7.c @@ -125,11 +125,15 @@ 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", GFP_KERNEL); + if (!new_compat->name || !new_compat->value) + return; of_update_property(np, new_compat); } diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c index a6b621ff0b87..8291185c52cc 100644 --- a/arch/arm/mach-mvebu/coherency.c +++ b/arch/arm/mach-mvebu/coherency.c @@ -191,7 +191,11 @@ static void __init armada_375_380_coherency_init(struct device_node *np) struct property *p; p = kzalloc(sizeof(*p), GFP_KERNEL); + if (!p) + return; p->name = kstrdup("arm,io-coherent", GFP_KERNEL); + if (!p->name) + return; of_add_property(cache_dn, p); } }