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 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 86157C38142 for ; Thu, 19 Jan 2023 18:03:27 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rft8wDOF4G+gsR49aP5Nwu4CZC1to5mB4ABWkj4NMvs=; b=guM1hWZLW3FsVN kQKwmht/rMGABsKQQ9k0ZQQ14pAk6ktqP9sHlmRt0Ed3MeuCRnp3jHsrv50kcvVI0gjwhzSlpmS8Z KaEuL5AuTnaHRb3Kf+6xxp9k1Fbd2/akaiZaJrKsFLAU8CL+Va1YZ73WoOnSvl7WnK9QH4P/QmG9i Yrvax8CmJ7BGobPGSG/cJOn7BffFdMA1WJcdxHKgUXh3qN34apUQgtWj/KY9q5qyKOrdz+67sSzCS bTpZYCjWkKCVxkI3xIwGGiwPhI4F0dkGf5LUs2tCFOoc99m1pZbOwBmQtA+6CX+hHDljmwXz0yIxR 0jyNupBEu2pluQF60U2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIZEb-006R0L-2P; Thu, 19 Jan 2023 18:01:57 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIZEY-006QzJ-GE for linux-arm-kernel@lists.infradead.org; Thu, 19 Jan 2023 18:01:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ch3G+TVl0zLt31mvi7p9Ehua4+39FF3iqi5hnpOXoh4=; b=e/K35kytzIPX47JGNKYJnUPu8X dIBnlvdGseBHIt9Fv6ze/kQbv6iaNjp6tBTxk0zO8QoyI9pEXfROAZ31YCGJd/bJ9pG6COUDxjskj HAGKUlpXJUMCR2QHmn/8xZR7fClFfuCAx/zAl6LYUuk4cf6X+l4PGaoJQLQqKDscRl4Xp+PYzJapY MdaANQQh5QQotDQvYOpIr5TisI+gdgqrcSUNbrUmcvICI6Sjc508eVvbzLZd7hpZYnLinD+9yfuPL 7/U8cdtf5jzDpDeZKzzVRXahmkq99JS8IhrtixgEJiAZJ9nXBF4PAiZTxV8rtcD0cZC0Sa1JlHdI4 b7SVEOLg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:36216) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pIZEW-0004pK-7c; Thu, 19 Jan 2023 18:01:51 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1pIZEU-0000fk-Vu; Thu, 19 Jan 2023 18:01:50 +0000 Date: Thu, 19 Jan 2023 18:01:50 +0000 From: "Russell King (Oracle)" To: ye.xingchen@zte.com.cn Cc: andrew@lunn.ch, gregory.clement@bootlin.com, sebastian.hesselbarth@gmail.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ARM: mvebu: potential dereference of null pointer Message-ID: References: <202301191051184033370@zte.com.cn> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <202301191051184033370@zte.com.cn> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230119_100154_581053_154BCFA9 X-CRM114-Status: GOOD ( 16.95 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jan 19, 2023 at 10:51:18AM +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 | 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; ... and then someone else comes along and spots that "new_compat" gets leaked, so we get another patch to add a kfree() for new_compat. Why not do the job properly first time around? > 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; Same problem here. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel