Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2349734ybb; Sun, 5 Apr 2020 05:22:48 -0700 (PDT) X-Google-Smtp-Source: APiQypJ8TCXlQF9cKHGUi0VsHRQ4vLW4eJHdJPdOG1R0JLKpe37kxoxM1cYvs51M1TVgUsFv9Xk4 X-Received: by 2002:a9d:3a1:: with SMTP id f30mr13334512otf.215.1586089368506; Sun, 05 Apr 2020 05:22:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586089368; cv=none; d=google.com; s=arc-20160816; b=mBzVsZENkHf8ZdEg3bGYfzQ4x74fGcZI4lGZ6Oazfmq2ezfCeAZ9BOwowPp01OqnRz s8ZHqUQCSbMlK2hMpua15S4eP/98a0SszMSoWaOWExsZTtlRCWZ32QGYaENmMRBaCc30 5Tlj9aympsZJ/5Psa9psGS4nOkD76fTfmFU1Nfi514rV38jeIG3q4566PBxF3cDLmcIE zjgUI8LO9oAwpbGFempsPe0OjvSj7NsQAe7iVAxNepkM1hS9XRZItBxOxVi6H8VNs00V wK+6FlkHDyK20+ZhjWDSpdIva1rPrQQoG5/86cDyuYqWfCBMLjSW58xoJ3X4iHETuUc2 Qn3Q== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=R6JUIvjpzPlO/CylALh6d2qFwDqIcytW6i19TRALkUw=; b=pqX+Ja1z6RHX4VG3AMVrlrjlR3upoWVJPDK1mDD18h/aun2jw3EEIQgznenMa8ABY0 vvD2RuK/LTbUECefB3Y7D23DJ3FXkTv37/om/NqCmjMktVddAMAWXTO91SMr1ZaxVa1n fzngbMz3rANPyI0VV3rpSGtOrQgN+YmHbrVefxJYBVXggx5kdPQEdyciKLwlvPSfcZcc QtrWrfYIyA7XFTttZjafJOrSAxlWVak/u5Pt1gDXAcbC3LMRQEszR5A6wSpm1T7fhaqw tmJWZjGQGeMtfxb/UIzUMmIcAMrkqxySdg77vMA624oev/seluNAj51jrUJkLCydP4hp mfmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hgkewgwL; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c19si6608007otr.276.2020.04.05.05.22.35; Sun, 05 Apr 2020 05:22:48 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hgkewgwL; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726638AbgDEMUX (ORCPT + 99 others); Sun, 5 Apr 2020 08:20:23 -0400 Received: from mail-il1-f194.google.com ([209.85.166.194]:42240 "EHLO mail-il1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726541AbgDEMUX (ORCPT ); Sun, 5 Apr 2020 08:20:23 -0400 Received: by mail-il1-f194.google.com with SMTP id f16so11980983ilj.9 for ; Sun, 05 Apr 2020 05:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=R6JUIvjpzPlO/CylALh6d2qFwDqIcytW6i19TRALkUw=; b=hgkewgwLG+H40zBE8TrLlml5d9v64hptp8pavEYfiMxq6a/6kqYkyiVxlzmw3HZw9k zTWyZzc5NtpPhlcLBfMK6PRjmRz5yR+lEiM9vvozLtynIKeKT06jd/WcmO9alx2pCzNy JE8GlVEL+zjdnQVFXcJ19LBxJZq0gtaHXoE2V8eezi3ySQQMPZ8N0G7pjIog92OFV2jY qi9y8dsUiejPx1qI4f/Qg7Xt2MBnHv4YGMRS8Vn+B23PazoWmHUjMDCQwgwl4SpMMFTW m8GJJBG4Yur7QL2rf11keafpd4l1G4UWy/8S1+PYA2bXjeNRr542b1QxO6PhSVSm7A+I mwgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=R6JUIvjpzPlO/CylALh6d2qFwDqIcytW6i19TRALkUw=; b=E8+u7h1uuWTJeTecby+F4BqT1R1LNP8mo2YmQZI+BLgUxxfUi6q6GciUDmsbp4R2qe vOtgPUnuplHJ45flhMEhn3KLPztW5lskmbiei2FfWIIiD12QEWl/vSIbYbRTgRzdYDH/ Nukrc7YKsguR06GBRmtM5dDagRdFggo2ih1j0P4gCpd7smZISoEKMEZEhZ+VSGQDjpxf mL54mo5SD/dI3V4h119Hwy9xPs7StIGhdbFZvn7V+rQtNhOKpWTwmV4TyvNyD3v6E4gz zneYrpKDFAfY3qLmIDMjDIrFXmf6zAFL+3W5QS1ouf6r/lDZLRc8rkT1l+stCVBO5ZoN BKHw== X-Gm-Message-State: AGi0PuZPjIIGXiyF/i4RbImqU1o8+Y3K3DtsrRSwWKaYDUeH2gltQuiZ 07LzcA4PRTRA3A90xJ0qq51nrs4za3GFNe7PKkA= X-Received: by 2002:a92:83ca:: with SMTP id p71mr15793373ilk.278.1586089222451; Sun, 05 Apr 2020 05:20:22 -0700 (PDT) MIME-Version: 1.0 References: <20200405103059.30769-1-hqjagain@gmail.com> <46e9dd45-c590-36c3-a60e-55750cde8935@c-s.fr> In-Reply-To: <46e9dd45-c590-36c3-a60e-55750cde8935@c-s.fr> From: Qiujun Huang Date: Sun, 5 Apr 2020 20:20:10 +0800 Message-ID: Subject: Re: [PATCH v2] powerpc/powernv: add NULL check after kzalloc in opal_add_one_export To: Christophe Leroy Cc: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, tglx@linutronix.de, linuxppc-dev@lists.ozlabs.org, LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Apr 5, 2020 at 8:12 PM Christophe Leroy w= rote: > > > > Le 05/04/2020 =C3=A0 12:30, Qiujun Huang a =C3=A9crit : > > Here needs a NULL check. > > > > Issue found by coccinelle. > > > > Signed-off-by: Qiujun Huang > > --- > > arch/powerpc/platforms/powernv/opal.c | 5 ++++- > > 1 file changed, 4 insertions(+), 1 deletion(-) > > > > diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platf= orms/powernv/opal.c > > index 2b3dfd0b6cdd..5b98c98817aa 100644 > > --- a/arch/powerpc/platforms/powernv/opal.c > > +++ b/arch/powerpc/platforms/powernv/opal.c > > @@ -808,9 +808,12 @@ static int opal_add_one_export(struct kobject *par= ent, const char *export_name, > > > > rc =3D of_property_read_u64_array(np, prop_name, &vals[0], 2); > > if (rc) > > - goto out; > > + return rc; > > Nice you changed that too. > > Then there is no need the initialise attr and name to NULL in their > declaration, as they won't be used before they are assigned. So that's it. > > > > > attr =3D kzalloc(sizeof(*attr), GFP_KERNEL); > > + if (!attr) > > + return -ENOMEM; > > + > > name =3D kstrdup(export_name, GFP_KERNEL); > > if (!name) { > > rc =3D -ENOMEM; > > > > Christophe