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.