Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7181289ybi; Thu, 1 Aug 2019 04:28:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqw2LzJYo3z5YS6LBabdLPMGL11PibpscPe//WCkZd7FpRFjV8jcCZ94yMbABzu2380KNv30 X-Received: by 2002:a63:394:: with SMTP id 142mr207269pgd.43.1564658903418; Thu, 01 Aug 2019 04:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564658903; cv=none; d=google.com; s=arc-20160816; b=zHjueRdIutQ4/S36eCtifr/L4eVyUqA6pfwfWUvNNokcOg2tc0Ev1AbQB65mHMGbnh lPMbKft3aZo0tTzNN7Pz4MAguvssE647/3p2NiuGziEhu4M7NwB4CXYrUqRTJlthybyt KuPjR/hiafZbpSBgWW84spr/A5w/ue9Zw7067e/OYzqJL9NnWYKhShzsyGnOl52F73k2 y+OOvrGim2cHgjxZAUZzU927WaADDGi6nPdBWwP9flzYiJdfHwiRq5q5LtcaLqNaMcof yQtlVoFjV1ge+9tNnLtXTvxYmIuAlLK39uw864S+q5rLtmvCXttQSRBau/XIOxLuNWS7 sW7A== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=f39NzAVLadX6RbMDgb/KiSl4JvrmYIW3Xcd6g66qQ8o=; b=PlrNEAGqjMszgjmt/dapnruF3duTHEz3dac+Z2CJ8m1D2UX64ylRJYXFdzX80HWSwW /Ps0PyWCvdXp1Q/BVS7YuJGvJs6Y3V587gN7OQvV0bR7tleXLbs5QSd7jtqEEq5JVGPM 8MfhENOwcsRjlne19zI+gfdV7dP/lwieVG2KfOk7VsXZZICGKMU2eRO7es4+K451bG05 S56jkD9qFdAxuGK4Trh3pg8i2+XegWjQaEN6Pzi01I1B3Ihdmp+VQFoH2MvDTirbg8xw WViOK61yY0AJgzhpG6lFbo2ahb0Atnj0lOevqsBL+fs+KEZjc0+G8bxw53G+lC2q5/4E Qe5Q== 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 bh2si32947805plb.116.2019.08.01.04.28.07; Thu, 01 Aug 2019 04:28:23 -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 S1731274AbfHAK5W (ORCPT + 99 others); Thu, 1 Aug 2019 06:57:22 -0400 Received: from 11.mo6.mail-out.ovh.net ([188.165.38.119]:54651 "EHLO 11.mo6.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726783AbfHAK5V (ORCPT ); Thu, 1 Aug 2019 06:57:21 -0400 X-Greylist: delayed 3599 seconds by postgrey-1.27 at vger.kernel.org; Thu, 01 Aug 2019 06:57:21 EDT Received: from player778.ha.ovh.net (unknown [10.108.35.95]) by mo6.mail-out.ovh.net (Postfix) with ESMTP id 0CCC21D1F9D for ; Thu, 1 Aug 2019 11:41:43 +0200 (CEST) Received: from kaod.org (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player778.ha.ovh.net (Postfix) with ESMTPSA id 5D8AE873BBDD; Thu, 1 Aug 2019 09:41:33 +0000 (UTC) Date: Thu, 1 Aug 2019 11:41:32 +0200 From: Greg Kurz To: Christophe JAILLET Cc: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, allison@lohutok.net, tglx@linutronix.de, clg@kaod.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH 2/2] powerpc/xive: Add a check for memory allocation failure Message-ID: <20190801114132.4c1db5be@bahia.lan> In-Reply-To: References: X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Ovh-Tracer-Id: 12958826454390118683 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduvddrleejgddujecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 1 Aug 2019 10:32:42 +0200 Christophe JAILLET wrote: > The result of this kzalloc is not checked. Add a check and corresponding > error handling code. > > Signed-off-by: Christophe JAILLET > --- Reviewed-by: Greg Kurz > Note that 'xive_irq_bitmap_add()' failures are not handled in > 'xive_spapr_init()' > I guess that it is not really an issue. This function is _init, so if a > memory allocation occures here, it is likely that the system will > already be in bad shape. Hmm not sure... The allocation could also fail if the "ibm,xive-lisn-ranges" property contains an insanely big range, eg. count == 1 << 31. The system isn't necessarily in bad shape in this case, but XIVE is definitely unusable and we should let a chance to the kernel to switch to XICS in this case. I guess it is worth adding proper error handling in xive_spapr_init() as well. > Anyway, the check added here would at least keep the data linked in > 'xive_irq_bitmaps' usable. > --- > arch/powerpc/sysdev/xive/spapr.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/arch/powerpc/sysdev/xive/spapr.c b/arch/powerpc/sysdev/xive/spapr.c > index b4f5eb9e0f82..52198131c75e 100644 > --- a/arch/powerpc/sysdev/xive/spapr.c > +++ b/arch/powerpc/sysdev/xive/spapr.c > @@ -53,6 +53,10 @@ static int xive_irq_bitmap_add(int base, int count) > xibm->base = base; > xibm->count = count; > xibm->bitmap = kzalloc(xibm->count, GFP_KERNEL); > + if (!xibm->bitmap) { > + kfree(xibm); > + return -ENOMEM; > + } > list_add(&xibm->list, &xive_irq_bitmaps); > > pr_info("Using IRQ range [%x-%x]", xibm->base,