Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2347684ybb; Sun, 5 Apr 2020 05:19:36 -0700 (PDT) X-Google-Smtp-Source: APiQypLWktq9cLEfRvpvW54C6OoAN0GR0tcYuZ/tFdGtpKT4Ebwy4NKPU9wfntmCjTcKNc48q81a X-Received: by 2002:aca:c7c5:: with SMTP id x188mr9566025oif.130.1586089176039; Sun, 05 Apr 2020 05:19:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586089176; cv=none; d=google.com; s=arc-20160816; b=0Yp2ln/pzu7uqlMEKkx2fEm4k1QNQeTtfJMVQHymQaF4VtZOydb4MSlrCqlb2EP4V8 f+8DEaoVRvqMocHRkw3At8wTt1ISDUnPX9dcUAKNbEm773480wbSsut53l3WmND32kUN 3bUZ1nyz5i7tujnnkIBAtNyfhC9nf6hRSGc3QQ0gGhBFhTCPCKYGcW0fEixL0+s57lbQ ETpAHFxFTUxKTWCyQq9V5z0Ller6BAr5E6B6EmMxKOdtDktC3VsT+Qw9SoJpNZi6k44N nPkRr4Lf6fFIweI8yz0pspLos3zOj/Blk7KfILslw/2CrNuwClkrgcaOorUyO78mQpS1 wbTA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=dks+FmlcH1P0YzNPFG6XPDO+hAdcRqA2bwD1oWlUYLk=; b=KaYxh4kfAFuS+wpd2emeM8yHSBkPEwqyHQ10L1ejQtR9fm2BwMW6fCX7FUAxubOLi2 hzypBSAc/d9Q7VZm4TmxVJ8iZDqKiAr6qunAC1vrYlXuMRuXMDylumq+8dg9lDf+F+9G WS4OCY4J3TXKNUjCupUD7oOUSMCvkM0a6NXSz5ZdoRnj84RBQAwJPQIxGCeeRWetdNzI HdhTYUilGSK+dquBNuPvFUUUeHHAQr180a8el5UZMBRDOAYUAdXBU/qgdNEdN7cdAnMD OLEhyYp2BFsFJm0VSqErV560timw4AsQyAV+6v28tWP6h3w5+jDt/0pEKwiID/oQUePA 7tbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=m9mQvPo4; 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 m9si6274823otp.239.2020.04.05.05.19.23; Sun, 05 Apr 2020 05:19:36 -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=@c-s.fr header.s=mail header.b=m9mQvPo4; 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 S1726582AbgDEMMq (ORCPT + 99 others); Sun, 5 Apr 2020 08:12:46 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:6601 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726541AbgDEMMq (ORCPT ); Sun, 5 Apr 2020 08:12:46 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 48wCGx6Qbbz9vDCS; Sun, 5 Apr 2020 14:12:41 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=m9mQvPo4; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id BU4CdYy38176; Sun, 5 Apr 2020 14:12:41 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 48wCGx4WMXz9vDCR; Sun, 5 Apr 2020 14:12:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1586088761; bh=dks+FmlcH1P0YzNPFG6XPDO+hAdcRqA2bwD1oWlUYLk=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=m9mQvPo4A9GDs7TwKbqCH2m5UFG2NLc/d7/M4So9D/O8vSy0xbYaXSfXXnOdjXq0E /C4P8egghAKNalNY8rHYJzt6PxtT2MsVaI1I/Y913IwMMqzQAg9ADOWz49E/tEulm4 BtByQADIpjrQie/1nkjs+GuEQAkxtmzh6+1zUpIE= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C82EB8B774; Sun, 5 Apr 2020 14:12:44 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id NHXes6cY9x8N; Sun, 5 Apr 2020 14:12:44 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id CE0298B764; Sun, 5 Apr 2020 14:12:43 +0200 (CEST) Subject: Re: [PATCH v2] powerpc/powernv: add NULL check after kzalloc in opal_add_one_export To: Qiujun Huang , benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, tglx@linutronix.de Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20200405103059.30769-1-hqjagain@gmail.com> From: Christophe Leroy Message-ID: <46e9dd45-c590-36c3-a60e-55750cde8935@c-s.fr> Date: Sun, 5 Apr 2020 14:12:29 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200405103059.30769-1-hqjagain@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 05/04/2020 à 12:30, Qiujun Huang a écrit : > 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/platforms/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 *parent, const char *export_name, > > rc = 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. > > attr = kzalloc(sizeof(*attr), GFP_KERNEL); > + if (!attr) > + return -ENOMEM; > + > name = kstrdup(export_name, GFP_KERNEL); > if (!name) { > rc = -ENOMEM; > Christophe