Message ID | 20221121100122.36528-1-zeming@nfschina.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp1492291wrr; Mon, 21 Nov 2022 02:13:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Y7mxQzKiIY0j7oLrYG40vual5OfEeHSM9LqfwcflbmZLDx6GdxbPPRCJvPEZkNdsbB3NY X-Received: by 2002:a17:90a:5918:b0:213:ff:1cda with SMTP id k24-20020a17090a591800b0021300ff1cdamr19155089pji.86.1669025620145; Mon, 21 Nov 2022 02:13:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669025620; cv=none; d=google.com; s=arc-20160816; b=ODnvDZgRQCRbpK8eTBatRfBOdbrgAEjSr1YnOhhZE/6dPgmjVL4ozbyvCCsR2J7pnN vDlIxppn17+sMeHKscV7eQtzAAmpBt532Ki4FOIgsqBXdpUxWOt1la9hJ9s+fL9DtP+H em3QS4v14Jtvezem2IeHmbGHt0u3y0EFRsKWgkB/z44pU+jvefTpDUUpqLZqs3yvFoAV DCEr9d7X8yAH74a/KZWLp3IBu8MoMndBX+a+31h7tq1rinHN/wYvdrCtxvGQeEDNyX5S TwGykEvtD6ziT2np42+yuSqh2fSPGmGfmg05kNwWeIfCUSEbVp8bjT0bPSQpj/ycIw8Q uqhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=Sbrf7ohkuqJEVudindk7hYG8sw2Z7iokmsqy0PAy7sU=; b=D5zDyBfHgtWJyvoqR9RmT29MZ1CZbXgVLDNf9hI/lOsva1pJNtgqIdLVaca6evFcYG KehZzDejeBwBzRlxNT0E9MtD6AAVkZthg1rTrG7IYEogR5axmiRyZt/BBa/QrZsImC84 odRhHS+9W3uhHm1GRz/OB0Mmfh3gTh4baAUJqvPSnmgRngjM3UdxauQOqkXLb+13/WZ2 UOCw9uAnoMnGtd7LyZxI5Hz8vKe8P2cwu4NKYLnTaVuBMkxxicmiRswTT8OQb/N3oAyi peYAzMcINFIBNTnG66NtdRIgBPtWET1rxxO18MvM062Qd8ELhCRba2IghupvX81NnJcO hMBQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b13-20020a6541cd000000b0047767ded526si3310948pgq.100.2022.11.21.02.13.25; Mon, 21 Nov 2022 02:13:40 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231210AbiKUKBv (ORCPT <rfc822;peter110.wang@gmail.com> + 99 others); Mon, 21 Nov 2022 05:01:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230478AbiKUKBg (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 21 Nov 2022 05:01:36 -0500 Received: from mail.nfschina.com (unknown [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 751ED52175 for <linux-kernel@vger.kernel.org>; Mon, 21 Nov 2022 02:01:35 -0800 (PST) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 775401E80DAB; Mon, 21 Nov 2022 17:58:07 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 504Ptf937N5n; Mon, 21 Nov 2022 17:58:04 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: zeming@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 308F21E80DAA; Mon, 21 Nov 2022 17:58:04 +0800 (CST) From: Li zeming <zeming@nfschina.com> To: andrew@lunn.ch, gregory.clement@bootlin.com, sebastian.hesselbarth@gmail.com Cc: linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Li zeming <zeming@nfschina.com> Subject: [PATCH] mach-mvebu: coherency: Judgment after pointer p increases allocation Date: Mon, 21 Nov 2022 18:01:22 +0800 Message-Id: <20221121100122.36528-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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?1750100208902567413?= X-GMAIL-MSGID: =?utf-8?q?1750100208902567413?= |
Series |
mach-mvebu: coherency: Judgment after pointer p increases allocation
|
|
Commit Message
Li zeming
Nov. 21, 2022, 10:01 a.m. UTC
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 <zeming@nfschina.com>
---
arch/arm/mach-mvebu/coherency.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Comments
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 <zeming@nfschina.com> > --- > 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
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); + } } }