Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6800706ybi; Mon, 22 Jul 2019 01:55:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIjTdyFil+DlYBtfVY3qjMGYS5LrI16s6EP1/0Ee+FwMg5oYpupc5dIec9jursyuqrJ/lv X-Received: by 2002:a63:c008:: with SMTP id h8mr67790569pgg.427.1563785732126; Mon, 22 Jul 2019 01:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563785732; cv=none; d=google.com; s=arc-20160816; b=LF1xqREhBvSkOhPXssipB0dyiJFu7sSm/Ya4Q3i/77TuAmm676c2tRdABP6lKm6Kyx 41rBDJaPZLhnqSuLQuWwGo4PimZZylgX5ATWtGxYPv8HBn3lrOvjyRXCxAGdya1vkqni 4GycN8AyRHkFICtGDIb6xX/qspx+JfqNy4WE06gnq8K71KJqo99MfEf5TYxnflFqrTmG shCnMhk+BEzE2VQWUyeFBEK7yvR0tydDgNbMt6fj9Ed44vdlDNwEKv0X15zugN2k8Jo3 qzM8pIqtp/5QFx/1CYTZLqZzgyYmzEa0BKJE11G9yj5522CaZc+tyI7oSReDeL3EPKwD k41A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from; bh=KsnCXzOJZBO8dbERxkRMLBwlyPJN+plUaO9A8AqzY94=; b=L5TUDUBSAJD/0E4ozgFevJJrM+x98C0amxW6sM7N28+dMSrzaywXebTBMyn1HmM8cf rV4z/26/zPotZ8HmkpYsDnKtm+e/kRiTtXEIZJlV+p+C10J7XmrVbxyEXTwWJvFj8anb jyeFpuc8U8ZS3dMIyCS1bjz6TepLMN57/H93aowHJJhFqAicXS4+xqAnuAO2jlKpD6Rl glANOcM3cwLn+O4+MS2Ggj/jeIdq/SjlpuccB5Km3nFOSYQL4sUohJ0P/CiLml+G1VSh 2UbXqWPexQ8VrnajuspgP3Z0fwDkITK0y3QRz1bpr+me90BKO5GD5SmUJvz+rtlCBJcP A6CQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 142si10414243pgf.35.2019.07.22.01.55.16; Mon, 22 Jul 2019 01:55:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728650AbfGVIys convert rfc822-to-8bit (ORCPT + 99 others); Mon, 22 Jul 2019 04:54:48 -0400 Received: from unicorn.mansr.com ([81.2.72.234]:60232 "EHLO unicorn.mansr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725989AbfGVIys (ORCPT ); Mon, 22 Jul 2019 04:54:48 -0400 Received: by unicorn.mansr.com (Postfix, from userid 51770) id 80C9215611; Mon, 22 Jul 2019 09:54:46 +0100 (BST) From: =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= To: Hariprasad Kelam Cc: Thomas Gleixner , Jason Cooper , Marc Zyngier , Marc Gonzalez , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH] irqchip/tango: Add NULL check after memory operation References: <20190721181536.GA13450@hari-Inspiron-1545> Date: Mon, 22 Jul 2019 09:54:46 +0100 In-Reply-To: <20190721181536.GA13450@hari-Inspiron-1545> (Hariprasad Kelam's message of "Sun, 21 Jul 2019 23:45:36 +0530") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hariprasad Kelam writes: > Add NULL check after kzalloc operation. > > Fix below issue reported by coccicheck > ./drivers/irqchip/irq-tango.c:189:1-5: alloc with no test, possible > model on line 193 > > Signed-off-by: Hariprasad Kelam > --- > 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 34290f0..761b9fa 100644 > --- a/drivers/irqchip/irq-tango.c > +++ b/drivers/irqchip/irq-tango.c > @@ -187,6 +187,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; > > -- Nothing checks the return value of that function, so bad things will still happen, only more confusing to debug. If you really want to "fix" this, you should either: - Simply panic() like the other error cases. If anything here fails, the system will not work anyway. - Replace the panic() calls with error returns and check the return value in tangox_of_irq_init(). The system will still end up unusable. -- M?ns Rullg?rd