Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2275498ybb; Sun, 5 Apr 2020 03:23:52 -0700 (PDT) X-Google-Smtp-Source: APiQypIYwUCAsw3KdWIneuQvQAOOhENiFAOqxJ5n7tlbuV/HopXZOvLwa5N8RfwCwTZ+j0S2B3ji X-Received: by 2002:aca:3b41:: with SMTP id i62mr8668436oia.55.1586082232770; Sun, 05 Apr 2020 03:23:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586082232; cv=none; d=google.com; s=arc-20160816; b=Fy0g/RW9nwJHOccURclFpUbY9omxAUfHwEoAByayR+GZHgFkTRcLq3pQA7MVkCQadx ynt0xJsCltQd4mWTSi7GCWVWNMO8qBOR41faMMc+Y0WLsz3tnytHDz5rnQa5lD2Oy4MW j7Sc5aUT1DrsdVmAfMqDUz9IFgmQbEElZdroxSylvDbs/ihuYFma+6OsZ/Sz8SU3hKUO 5nhoxZf6q3BCsJlHNWaUy6iW/xk7uosBtexEWlQMh/0MUHSHjfyUQ2idlAE1z1SKM5qT vlbP6CERbDjtWjiS0GNgEszUiSoZmxCbXakClm7g1Kr1uaNNhkl/t3BtyeQIBHmyd4IB i6rw== 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=CcpZ55sIaW80vBf2IOXi5oS4UvwpWuI+r7GfFf/L5RY=; b=YnDvsGdv5MHpMoGK8WQHx4Vz6kXxTBv6z1w5WywetXtbfhkPKTijO+h0XC0uZKsIhk RNv4Us6+mXWo3OtoATw0ez/ksals2ZM1r1t+5q4BQBCeBbGknCP1CQuLtGi1ZwxOcEZJ KuRDxNjtgt9WOVwsGXXIx6Dcxm2elSvbo1GV3CP0cknaNKM+Q4pBYl38RgPhX6dTtLev 7nbLoe/Sc+bySUwOIKgpzrFpicO+sKfzbdBNh991u6BaM+xXsuIQyeLzoOVKNC1j4vLL dPgpm5gclzPtnnBfllgnOYXJ4OPKQM0hbTWZIpJD9L2k+hmC7gj7rBmfqEX2hZsXSXbT VvOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=IkXSasLQ; 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 d4si6644291ood.77.2020.04.05.03.23.33; Sun, 05 Apr 2020 03:23:52 -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=IkXSasLQ; 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 S1726474AbgDEKWE (ORCPT + 99 others); Sun, 5 Apr 2020 06:22:04 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:37166 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbgDEKWD (ORCPT ); Sun, 5 Apr 2020 06:22:03 -0400 Received: by mail-io1-f67.google.com with SMTP id q9so12543138iod.4 for ; Sun, 05 Apr 2020 03:22:03 -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=CcpZ55sIaW80vBf2IOXi5oS4UvwpWuI+r7GfFf/L5RY=; b=IkXSasLQ9grTa++au/Z5hXPOKZ3ZYi+1JzuViyhA0HLbYf0TxrRQXTwA9oh8IWSDi8 dzdpEl2smjGu27eIT7o5v8nOu8XP0B0lJr4jqEisaOuLgNSJsaJnx/WVlQjQCTzZliM1 ED+serjzQZUw9NU+mOG7b8c/g0O5j4V+5G5QaGdwVPxPzaEN7h9TMFRIa6Xwf3ReS/d8 1IIjeLFvSMjo2NJUER3BzVCwPsjIDncOnhahCE+euDnJ5TBQFxPAJZfYZsgtQiCvaIpG 873oPWRQQLsu0YKt0vGP6KcE++U77GXyZCJAytUJ+zFCYr076Qn6O8D1ToIHLPQAmyPr RsaA== 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=CcpZ55sIaW80vBf2IOXi5oS4UvwpWuI+r7GfFf/L5RY=; b=skMFwMHWp6duOKpv7vcC51mD8Uw0ceP+0usaXIMe8fao3DyuG27hGnRthLV7WtGnnu B6kvXPSrAeQm9ndsxIA7dMcLeFGBIWWIt3/4PmLOY7V94zdhKQ1r7iqN84qDXS44RPKd 84F4C2+Cl5UrPfYkOJDZswoV4k2NgRUVH0AOJImep6I5PwVKyx4mjk1ozMQOmhiKZW5j BDHeR0O2VxS96qQM6NtWvIzrxKt1sLUDi0et5QfKFk6HycXQKkI/D9/gIxaNU34YQ/hD H+Y1ZHMG2syCmtP6FK0KhVKyfkQ1fx+Vu3ZZKwfz883P2U4nzNNbfPBIf2yxcY3Kwc0q oyjw== X-Gm-Message-State: AGi0PuZGEfs1cPGEqnPtCbYjccBfBNgKBCg/NdJRBihYGsCFjdq9dlf1 B2OozO5/TCk5xdGy6E8Nx+NyWJ1fIq2kzzZzzpRBXr8h X-Received: by 2002:a5d:984b:: with SMTP id p11mr15046520ios.175.1586082122447; Sun, 05 Apr 2020 03:22:02 -0700 (PDT) MIME-Version: 1.0 References: <20200405075123.28756-1-hqjagain@gmail.com> <99de2220-5a64-e81e-6886-447296431548@c-s.fr> In-Reply-To: <99de2220-5a64-e81e-6886-447296431548@c-s.fr> From: Qiujun Huang Date: Sun, 5 Apr 2020 18:21:49 +0800 Message-ID: Subject: Re: [PATCH] powerpc/powernv: add NULL check after kzalloc in opal_add_one_export To: Christophe Leroy Cc: benh@kernel.crashing.org, paulus@samba.org, 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 6:13 PM Christophe Leroy w= rote: > > > > Le 05/04/2020 =C3=A0 09:51, 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, 5 insertions(+) > > > > diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platf= orms/powernv/opal.c > > index 2b3dfd0b6cdd..09443ae3a86e 100644 > > --- a/arch/powerpc/platforms/powernv/opal.c > > +++ b/arch/powerpc/platforms/powernv/opal.c > > @@ -811,6 +811,11 @@ static int opal_add_one_export(struct kobject *par= ent, const char *export_name, > > goto out; > > > > attr =3D kzalloc(sizeof(*attr), GFP_KERNEL); > > + if (!attr) { > > + rc =3D -ENOMEM; > > + goto out; > > You don't need to go to out:, there is nothing to do. You should do: > > if (!attr) > return -ENOMEM; Yeah, I get that. Thanks. > > > + } > > + > > name =3D kstrdup(export_name, GFP_KERNEL); > > if (!name) { > > rc =3D -ENOMEM; > > > > Christophe