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 X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D189C169C4 for ; Tue, 29 Jan 2019 08:55:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D1A77214DA for ; Tue, 29 Jan 2019 08:55:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726992AbfA2Izq (ORCPT ); Tue, 29 Jan 2019 03:55:46 -0500 Received: from foss.arm.com ([217.140.101.70]:60240 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725298AbfA2Izp (ORCPT ); Tue, 29 Jan 2019 03:55:45 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8046C80D; Tue, 29 Jan 2019 00:55:45 -0800 (PST) Received: from big-swifty.misterjones.org (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 36F883F7A6; Tue, 29 Jan 2019 00:55:43 -0800 (PST) Date: Tue, 29 Jan 2019 08:55:41 +0000 Message-ID: <86a7jjvo4y.wl-marc.zyngier@arm.com> From: Marc Zyngier To: YueHaibing Cc: , , , , , Subject: Re: [PATCH -next] irqchip/tango: Fix potential NULL pointer dereference In-Reply-To: <20190129080122.20392-1-yuehaibing@huawei.com> References: <20190129080122.20392-1-yuehaibing@huawei.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 29 Jan 2019 08:01:22 +0000, YueHaibing wrote: > > There is a potential NULL pointer dereference in case kzalloc() > fails and returns NULL. > > Fixes: 4bba66899ac6 ("irqchip/tango: Add support for Sigma Designs SMP86xx/SMP87xx interrupt controller") > Signed-off-by: YueHaibing > --- > drivers/irqchip/irq-tango.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/irqchip/irq-tango.c b/drivers/irqchip/irq-tango.c > index ae28d86..a63b828 100644 > --- a/drivers/irqchip/irq-tango.c > +++ b/drivers/irqchip/irq-tango.c > @@ -191,6 +191,8 @@ static int __init tangox_irq_init(void __iomem *base, struct resource *baseres, > panic("%pOFn: failed to get address", node); > > chip = kzalloc(sizeof(*chip), GFP_KERNEL); > + if (!chip) > + return -ENOMEM; > chip->ctl = res.start - baseres->start; > chip->base = base; > This is a commendable effort, but given that the whole error handling of this driver is just to simply panic, I have the ugly feeling that this lack of check is more a feature than a bug... Not that I like it, but at least it is consistent. If you're going to change that, I'd recommend you overhaul the whole thing. Thanks, M. -- Jazz is not dead, it just smell funny. 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 X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D43FDC282C7 for ; Tue, 29 Jan 2019 08:56:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A3522214DA for ; Tue, 29 Jan 2019 08:56:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Feoh88N7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A3522214DA Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zdXqbhu6QzwtZcrrQ74/xTlzfYKd40gHSaRynhs8mKg=; b=Feoh88N7wvphm8 VD4D+aUk2rU9YPkpWfTsADprYTNNCsvq0+7F3E6eEUsiIusGpAsEp3JN9YPOZnmJiO6o7wrAXjHgj mjEmnOmsVzKrMG1D+GOoFm6nbr9sULU8BqVWIdgXNgNWTQVReQUaKcImvxMRp2G9nRtlRf10bgFjv Q+sk3a7gl4yzYR7TjN24T04F78zccLsottdjAX7RtKUSXdSDHIEF7/wQZ8PPONjT2iHnuhP8tYDa6 U0oQOoCasiVNiOZepGtHkXG8ftAVKH2hrnrtHKvDXciJE88tnKPs2fXUD/ICL/D7QREMUbvrpoY1N prPsY6JlYWPIVEMTbpTA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1goPBX-0003En-I3; Tue, 29 Jan 2019 08:55:59 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1goPBL-00032T-0z for linux-arm-kernel@lists.infradead.org; Tue, 29 Jan 2019 08:55:58 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8046C80D; Tue, 29 Jan 2019 00:55:45 -0800 (PST) Received: from big-swifty.misterjones.org (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 36F883F7A6; Tue, 29 Jan 2019 00:55:43 -0800 (PST) Date: Tue, 29 Jan 2019 08:55:41 +0000 Message-ID: <86a7jjvo4y.wl-marc.zyngier@arm.com> From: Marc Zyngier To: YueHaibing Subject: Re: [PATCH -next] irqchip/tango: Fix potential NULL pointer dereference In-Reply-To: <20190129080122.20392-1-yuehaibing@huawei.com> References: <20190129080122.20392-1-yuehaibing@huawei.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) 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") X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190129_005547_067640_F2F57F8D X-CRM114-Status: GOOD ( 17.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mans@mansr.com, jason@lakedaemon.net, marc.w.gonzalez@free.fr, linux-kernel@vger.kernel.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 29 Jan 2019 08:01:22 +0000, YueHaibing wrote: > > There is a potential NULL pointer dereference in case kzalloc() > fails and returns NULL. > > Fixes: 4bba66899ac6 ("irqchip/tango: Add support for Sigma Designs SMP86xx/SMP87xx interrupt controller") > Signed-off-by: YueHaibing > --- > drivers/irqchip/irq-tango.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/irqchip/irq-tango.c b/drivers/irqchip/irq-tango.c > index ae28d86..a63b828 100644 > --- a/drivers/irqchip/irq-tango.c > +++ b/drivers/irqchip/irq-tango.c > @@ -191,6 +191,8 @@ static int __init tangox_irq_init(void __iomem *base, struct resource *baseres, > panic("%pOFn: failed to get address", node); > > chip = kzalloc(sizeof(*chip), GFP_KERNEL); > + if (!chip) > + return -ENOMEM; > chip->ctl = res.start - baseres->start; > chip->base = base; > This is a commendable effort, but given that the whole error handling of this driver is just to simply panic, I have the ugly feeling that this lack of check is more a feature than a bug... Not that I like it, but at least it is consistent. If you're going to change that, I'd recommend you overhaul the whole thing. Thanks, M. -- Jazz is not dead, it just smell funny. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel