From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751463AbdAQKZs (ORCPT ); Tue, 17 Jan 2017 05:25:48 -0500 Received: from foss.arm.com ([217.140.101.70]:46096 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751360AbdAQKZq (ORCPT ); Tue, 17 Jan 2017 05:25:46 -0500 Subject: Re: [PATCH v1] irqchip: irq-mips-gic:- Handle return NULL error from ioremap_nocache To: Matt Redfearn , Arvind Yadav , tglx@linutronix.de, jason@lakedaemon.net References: <1483949306-9712-1-git-send-email-arvind.yadav.cs@gmail.com> <120995f1-6cdb-9736-f6da-b85925f27451@arm.com> <4b306a43-7b8f-e4c4-95f8-bb0cd52f4336@gmail.com> <574c27a3-cee8-6649-ef20-9903a1d9850d@imgtec.com> Cc: linux-kernel@vger.kernel.org, Linux MIPS Mailing List From: Marc Zyngier Organization: ARM Ltd Message-ID: <7b1e2045-9e3c-7101-8750-1c6db90e5953@arm.com> Date: Tue, 17 Jan 2017 10:25:29 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.5.1 MIME-Version: 1.0 In-Reply-To: <574c27a3-cee8-6649-ef20-9903a1d9850d@imgtec.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/01/17 10:17, Matt Redfearn wrote: > > > On 17/01/17 10:10, Arvind Yadav wrote: >> Hi Matt, >> >> Please Acknowledge this. >> >> Regards >> Arvind Yadav > > Hi Arvind, > > Acked-by: Matt Redfearn > > >> >> On Monday 09 January 2017 02:30 PM, Marc Zyngier wrote: >>> On 09/01/17 08:08, Arvind Yadav wrote: >>>> Here, If ioremap_nocache will fail. It will return NULL. >>>> Kernel can run into a NULL-pointer dereference. >>>> This error check will avoid NULL pointer dereference. >>>> >>>> Signed-off-by: Arvind Yadav >>>> --- >>>> drivers/irqchip/irq-mips-gic.c | 2 ++ >>>> 1 file changed, 2 insertions(+) >>>> >>>> diff --git a/drivers/irqchip/irq-mips-gic.c >>>> b/drivers/irqchip/irq-mips-gic.c >>>> index c01c09e..eeea2e8 100644 >>>> --- a/drivers/irqchip/irq-mips-gic.c >>>> +++ b/drivers/irqchip/irq-mips-gic.c >>>> @@ -979,6 +979,8 @@ static void __init __gic_init(unsigned long >>>> gic_base_addr, >>>> __gic_base_addr = gic_base_addr; >>>> gic_base = ioremap_nocache(gic_base_addr, gic_addrspace_size); >>>> + if (!gic_base) >>>> + panic("Failed to map GIC memory"); >>> So you're replacing a panic due to dereferencing a NULL pointer with >>> another panic -- not much progress here. I appreciate that the message >>> is a bit more explicit, but is there something slightly less drastic we >>> could do? Like returning an error code and see if the kernel otherwise >>> recovers (possibly with reduced functionality)? > > Marc, there's really not much that can be done without the GIC > initializing sucessfully. This should not happen if platform code / > device tree is set up correctly, so an explicit panic if that is not the > case is helpful. Fair enough, that's your call. I'll pick that up as is. Thanks, M. -- Jazz is not dead. It just smells funny...