Message ID | 202301171822040406304@zte.com.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1675033wrn; Tue, 17 Jan 2023 02:22:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXvK0GDJszqAJmX7Kat44/XPhRScBrdKTdJx3H5NjCb+mmGBNSJhxIW0X1EeTdyWHO/u1cBh X-Received: by 2002:a05:6a20:9e4a:b0:9d:efbf:48de with SMTP id mt10-20020a056a209e4a00b0009defbf48demr2388605pzb.34.1673950973476; Tue, 17 Jan 2023 02:22:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673950973; cv=none; d=google.com; s=arc-20160816; b=DgL/lta0oySMcHkkCScVRw0S4rE44kzp5sA4M5AnD7Tb3An9/NWcbffJ1gxth4VVue 3qwkptCrfK4OUAJW3bK45/jbMOc0EcVx1G+3X3hLkIC6Q828ZR3TcLyNfu3aW8OQM8bX h+Kt4I7V12CgO7d7c0hUeAFjM7OdlcUvH1skOL4u+o6pKOmO9EJ90iAgxif7NS2QkqVX GZ85B7ibuSrk1m8o2+dvXpXTnurK5TbvnSTs8TqTJ1EfZIEppCdVwm+LVf3Fjqau9Ro4 31WqcZ/e0bTm87PBNXu0q5n48IDLqNOiKx1nyTZo9Dwso3XfRHKmE3PzlXAvNYJONeD2 Yytg== 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=dJ+QqgZoqXPxQcjLNKqfk3hIEEEa54CjYDyOaBQhkCM=; b=yURpuOAXKnnJEZ/2xwWZERUvzWuSQB7V36LIYteARwBFuGlu7f5ni5K0gqog3GyHvc Co/RlRmrqqfh0pWimbcsUnwGjf4UWg3tye/bBhCBc+b2XEH5bfHCtla/0j2Kp3Ta6zQB 9zQNchR2vf96rYPwTRAN1OIwT3Sx6MqtopmyzJDftsdZ9lYUOqdMNfxAaK/pIo9FdqDR sjjIYVN8XE1yTIoGd0O+vyMmYItUZj9gKP+5oW1LzMLot70R9P1ANoOXq/V56mM4XQgk 7wREdsLz4SUL+3ZSeZaCBvDh7667VuameOe2bJfMVDHSO6cfdpC5DsNbBMQa0A0Vj08n dWpw== 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 k133-20020a636f8b000000b004ba3656506csi18179175pgc.559.2023.01.17.02.22.40; Tue, 17 Jan 2023 02:22:53 -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 S236532AbjAQKWO (ORCPT <rfc822;pfffrao@gmail.com> + 99 others); Tue, 17 Jan 2023 05:22:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236148AbjAQKWM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 17 Jan 2023 05:22:12 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21E0C26593 for <linux-kernel@vger.kernel.org>; Tue, 17 Jan 2023 02:22:11 -0800 (PST) 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: <ye.xingchen@zte.com.cn> To: <andrew@lunn.ch> Cc: <gregory.clement@bootlin.com>, <sebastian.hesselbarth@gmail.com>, <linux@armlinux.org.uk>, <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <chi.minghao@zte.com.cn> Subject: =?utf-8?q?=5BPATCH=5D_ARM=3A_mvebu=3A_potential_dereference_of_null?= =?utf-8?q?_pointer?= Content-Type: text/plain; charset="UTF-8" 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/<ye.xingchen@zte.com.cn> X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63C676D0.000/4Nx4h023LVz6FK2P 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755264815998985874?= X-GMAIL-MSGID: =?utf-8?q?1755264815998985874?= |
Series |
ARM: mvebu: potential dereference of null pointer
|
|
Commit Message
ye.xingchen@zte.com.cn
Jan. 17, 2023, 10:22 a.m. UTC
From: Minghao Chi <chi.minghao@zte.com.cn> 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 <zealci@zte.com.cn> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn> --- arch/arm/mach-mvebu/board-v7.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Tue, Jan 17, 2023 at 06:22:04PM +0800, ye.xingchen@zte.com.cn wrote: > From: Minghao Chi <chi.minghao@zte.com.cn> > > 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 <zealci@zte.com.cn> > Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn> > Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn> > --- > 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", Please add a blank line after the return statement. Also, i find it interested your bot is telling you about kzalloc, but totally ignoring kstrdup(). Andrew
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",