From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3691C38147 for ; Wed, 18 Jan 2023 13:47:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229695AbjARNrV (ORCPT ); Wed, 18 Jan 2023 08:47:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230420AbjARNqy (ORCPT ); Wed, 18 Jan 2023 08:46:54 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62C8F65F37 for ; Wed, 18 Jan 2023 05:17:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=wd8rPoxSEOy2m/HQXKKEeOnbpnN+wzZH84RSXywB5Ok=; b=kE12tB6grAfclGwnHOd+B8gs3P ee+o8Uvt7azWscY1yd/rzi99XHXgRxhfEZHn3R39jBOfiABbzgWc4sjLQpcO6vTXBE9qItBwbepl4 UQxUcDsLwQLTLYQSYGcgCym4IBystWypGQa/JE3RPThemi/PaDlifX2DjigSh2g97v88=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pI8JI-002RSP-El; Wed, 18 Jan 2023 14:17:00 +0100 Date: Wed, 18 Jan 2023 14:17:00 +0100 From: Andrew Lunn To: ye.xingchen@zte.com.cn 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: Re: [PATCH] ARM: mvebu: potential dereference of null pointer Message-ID: References: <202301171822040406304@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202301171822040406304@zte.com.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 17, 2023 at 06:22:04PM +0800, ye.xingchen@zte.com.cn wrote: > 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", 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