Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5090950rwb; Mon, 21 Nov 2022 16:39:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf5DZYZ/vdJPddXN+9da7ug3uB1+Lxhyi4unpw3oWeEffKfoBLBD4+WT6uCXr1o3OC2l2Zea X-Received: by 2002:a05:6402:2b87:b0:45b:c731:b683 with SMTP id fj7-20020a0564022b8700b0045bc731b683mr19630327edb.251.1669077570753; Mon, 21 Nov 2022 16:39:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669077570; cv=none; d=google.com; s=arc-20160816; b=n6pWNbII/DPlkEabW6ypozSr4SBe+sJPBh/o90aFMWFwiU04zmxqfER5Pz7Myd6MgQ wRwpAKIE/Fjh8FN3EfXOdn5RwWUQd6wWzCymFgOOBegk9s02F7t+W40hYSIjTY1Jd+w7 n4JG+wU89bX5Hl4yKX0CMkXquN0p9Ede9nQkKVxDSpd8acAcGTjBtN/xIWpSb77FdERj FfgUdtcA3d7HmD7kJv4ozhwwBOB+QwQPGIVSilBIwqSD2rf7kZz8XnesQ9BeRtYePbMh MPK0Sw1OzT9fg9iDZYtQYqcxJ2g2tSYV5WCovjCmJxHM9m5k4YvpTwAsOfXztHJ1Gy+3 +Ozg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=OAzB8I2tTwLyGBq73vdy7J6qBtfQjMwcJ1th7CwFohY=; b=sR7ghzyytZHSt/84tmZWTk2oEfv+RkRwI1m6f+h516GeKEiavwb1dj3TvNDfX2eLC4 QQAYuMUyXLn4RIPbMqisAoQalW6pdxEjaKpFTpybRaMb/SxyEWNMCNzJKzUHkMvR6u1f xvQhPRddry6cwjxgMWOquSGMq7rfy/62jNcHoNkumooWlt8b0yeURitCoQMHyJvtLcoI 0P/G9pO97VRM+77feZ0rMRVNJ0D31zeXgLKb3ogzqkmTHuZ+ARs16WPDB2eA4MTwRz2j rcRdjgmbHpCEmuL+PRMHPFLXRc2X2YpECc6bsgXwGBTMhxU+JRcTuJqYSuFDXnK/s+l+ xumg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=uJgBYK0K; 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=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f17-20020a056402355100b00463a583166asi11637668edd.197.2022.11.21.16.39.08; Mon, 21 Nov 2022 16:39: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; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=uJgBYK0K; 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=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229920AbiKVAUi (ORCPT + 91 others); Mon, 21 Nov 2022 19:20:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229682AbiKVAUg (ORCPT ); Mon, 21 Nov 2022 19:20:36 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8F879AC8B for ; Mon, 21 Nov 2022 16:20:34 -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=OAzB8I2tTwLyGBq73vdy7J6qBtfQjMwcJ1th7CwFohY=; b=uJgBYK0K8+A5Wga+o75EPm0L9e mMkCxGpo+6VsBCHMPZIphjXWmj5oz/+PPQqSlSIq92SqlmJutad3Hc2lCk3tsS+9p0HMLCPCBC/0Q BUImHbGSyPDkJbmL7XTkCW3WFkpq43kuHK++frlNeHlFomrfWC65awbvf6trKWIK3Gz4=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1oxH0j-0034Ah-0c; Tue, 22 Nov 2022 01:19:37 +0100 Date: Tue, 22 Nov 2022 01:19:36 +0100 From: Andrew Lunn To: Li zeming Cc: gregory.clement@bootlin.com, sebastian.hesselbarth@gmail.com, linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mach-mvebu: coherency: Judgment after pointer p increases allocation Message-ID: References: <20221121100122.36528-1-zeming@nfschina.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221121100122.36528-1-zeming@nfschina.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS 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 On Mon, Nov 21, 2022 at 06:01:22PM +0800, Li zeming wrote: > Add judgment statements at the position after pointer p allocates memory > to avoid the abnormal impact of low probability allocation failure. > > Signed-off-by: Li zeming > --- > arch/arm/mach-mvebu/coherency.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c > index a6b621ff0b87..2bc69dd059d6 100644 > --- a/arch/arm/mach-mvebu/coherency.c > +++ b/arch/arm/mach-mvebu/coherency.c > @@ -191,8 +191,10 @@ static void __init armada_375_380_coherency_init(struct device_node *np) > struct property *p; > > p = kzalloc(sizeof(*p), GFP_KERNEL); > - p->name = kstrdup("arm,io-coherent", GFP_KERNEL); > - of_add_property(cache_dn, p); > + if (p) { > + p->name = kstrdup("arm,io-coherent", GFP_KERNEL); > + of_add_property(cache_dn, p); > + } The comment before this says: /* * Add the PL310 property "arm,io-coherent". This makes sure the * outer sync operation is not used, which allows to * workaround the system erratum that causes deadlocks when * doing PCIe in an SMP situation on Armada 375 and Armada * 38x. */ Skipping adding the property because we are out of memory is probably not a good idea, it is going to cause very hard to find deadlocks. Actually being out of memory so early in the boot indicates something very bad is going on anyway. So i think dereferencing the NULL pointer is the least of our worries. If you really want to do some sort of check here, BUG_ON(!p); Andrew