From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756237AbeDXHV6 (ORCPT ); Tue, 24 Apr 2018 03:21:58 -0400 Received: from foss.arm.com ([217.140.101.70]:48710 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756202AbeDXHVy (ORCPT ); Tue, 24 Apr 2018 03:21:54 -0400 Date: Tue, 24 Apr 2018 08:21:42 +0100 Message-ID: <8636zlnk6x.wl-marc.zyngier@arm.com> From: Marc Zyngier To: YueHaibing Cc: , , Subject: Re: [PATCH] irqchip/gic-v3: check kasprintf() for failures In-Reply-To: <20180424071036.20188-1-yuehaibing@huawei.com> References: <20180424071036.20188-1-yuehaibing@huawei.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 EasyPG/1.0.0 Emacs/25.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Organization: ARM Ltd MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 24 Apr 2018 08:10:36 +0100, YueHaibing wrote: > > We should just return -ENOMEM here if the allocation fails, > otherwise it may cause a panic. Can you explain how? From what I can see, node_name is only used as a parameter to pr_err/pr_info, which will perfectly deal with it by printing "(null)", and not causing a panic. Am I missing something? > > Signed-off-by: YueHaibing > --- > drivers/irqchip/irq-gic-v3-its-pci-msi.c | 3 +++ > drivers/irqchip/irq-gic-v3-its-platform-msi.c | 3 +++ > 2 files changed, 6 insertions(+) > > diff --git a/drivers/irqchip/irq-gic-v3-its-pci-msi.c b/drivers/irqchip/irq-gic-v3-its-pci-msi.c > index 25a98de..ef3911f 100644 > --- a/drivers/irqchip/irq-gic-v3-its-pci-msi.c > +++ b/drivers/irqchip/irq-gic-v3-its-pci-msi.c > @@ -160,6 +160,9 @@ its_pci_msi_parse_madt(struct acpi_subtable_header *header, > its_entry = (struct acpi_madt_generic_translator *)header; > node_name = kasprintf(GFP_KERNEL, "ITS@0x%lx", > (long)its_entry->base_address); > + if(!node_name) Missing space. > + return -ENOMEM; > + > dom_handle = iort_find_domain_token(its_entry->translation_id); > if (!dom_handle) { > pr_err("%s: Unable to locate ITS domain handle\n", node_name); > diff --git a/drivers/irqchip/irq-gic-v3-its-platform-msi.c b/drivers/irqchip/irq-gic-v3-its-platform-msi.c > index 8881a05..b676fb4 100644 > --- a/drivers/irqchip/irq-gic-v3-its-platform-msi.c > +++ b/drivers/irqchip/irq-gic-v3-its-platform-msi.c > @@ -126,6 +126,9 @@ its_pmsi_parse_madt(struct acpi_subtable_header *header, > its_entry = (struct acpi_madt_generic_translator *)header; > node_name = kasprintf(GFP_KERNEL, "ITS@0x%lx", > (long)its_entry->base_address); > + if(!node_name) > + return -ENOMEM; > + > domain_handle = iort_find_domain_token(its_entry->translation_id); > if (!domain_handle) { > pr_err("%s: Unable to locate ITS domain handle\n", node_name); > -- > 2.7.0 > > Thanks, M. -- Jazz is not dead, it just smell funny.