Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2185977ybb; Sun, 5 Apr 2020 00:54:27 -0700 (PDT) X-Google-Smtp-Source: APiQypI03hJDjkgrET1C7UoWkR5QD5rR5WjXMFZW3sjT2Qdx4Tdf4KsbVzpSLTi2WSUU26Ns9hg+ X-Received: by 2002:a05:6830:1697:: with SMTP id k23mr12322705otr.1.1586073267437; Sun, 05 Apr 2020 00:54:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586073267; cv=none; d=google.com; s=arc-20160816; b=G2kuuqX9bUIAqSZS7eSVPFKg1ZeSZ+9H0gfmNZOYdfsvVp7jzSSEe0ZWqpkr89sQ0C +sN7e9B2Gs2JNNPkVkry0488N79WkAeb2Ai8x1jCUUuZmaGYAX+xRF5YROS8Ne8XOD39 SRpsRrOgSoO6XgBzvqtRuYXu3JU5jc7UGwJgS6pM0Q2qOKz3UEm0ldu7lS3fVtH8TX5g eIhebURAGnZ/U5xcrbLDonHYJnEF2jyKAzm5iJl7+wSGrTvDysJnI6jnXckzkvDV0sUs erzmWz1nJITMRD/owCFb21kbx0swiXvhRBojjMQbWRL6gweAAx9AvU01dC3FkPMzlATM pqAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=fXHW1b6fO1FXiuIvfxLCGqRbJU/6omAN7vseOtHgP2o=; b=c9lClz0cDrZnWd7TzyHbZkQ2i7PjhvE/YS1FkIx/xqLG9p7ode7wEnZOLVluiUVN1Z lrH2iw+srP83x95dT2dMzuNRb1QXaH2SVC5q3gI6ZOnCUneexST/PZrsAW9RoboLFm+g Hj7M3pxBABadc/bCVZgNogBcSE6DwSEZfHPhfp6Y9DCVoepc55i+1lLRGb3d2bETizh2 sbCDWju4Ka7b0VvWgd0y+iTd6m/7CRyp7nPby+fSLUY3As1ko429YmfdCRRCEVZtXJcW 3YPxsevYfmoyb8ffOgvMOcn0hXZieLz540Rr2E8yZDhHjOm+xJBHnDLwGVaJ7wIahQ42 xu9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=psSUHWRl; 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 i142si5886230oib.87.2020.04.05.00.54.05; Sun, 05 Apr 2020 00:54:27 -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=psSUHWRl; 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 S1726397AbgDEHvd (ORCPT + 99 others); Sun, 5 Apr 2020 03:51:33 -0400 Received: from mail-pj1-f65.google.com ([209.85.216.65]:51536 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726364AbgDEHvc (ORCPT ); Sun, 5 Apr 2020 03:51:32 -0400 Received: by mail-pj1-f65.google.com with SMTP id w9so5123083pjh.1 for ; Sun, 05 Apr 2020 00:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=fXHW1b6fO1FXiuIvfxLCGqRbJU/6omAN7vseOtHgP2o=; b=psSUHWRluSuqiIOUXhePdO1uO71WyIsrMBA8Bwpc1s1/RHSbWS9NGikzTh9SWUQ4lB vKbwIyi85w0j1k5NIMcV9Evw65Jjf5JSXV1lGJfVPqMTnbF7Cor/MSocRiCc7MFvIQgR Wrb89k6Sw3LROe5XzNSM5KBgv4X77DaRxPY+At9qMWjUZ1/dmsGZKDLf/hPQBLanE4X/ scYLCRz7i8S2l9bGdRRSJyWo8xCaZMe8pNUCktkTErivMoBAIH8I6JpoZ5t7a9ki9/GE l0Dv1gx0PXHgwDuWdq7IG+wYS/i5MUSGa5Gsgq81JocvMw++a5H2Tj8IWmL60DyBV2QF cbEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=fXHW1b6fO1FXiuIvfxLCGqRbJU/6omAN7vseOtHgP2o=; b=fGcpdRnLrLI61QxgZOmkq3hC+t+iIvZzrl1B+g2maNYyhtdy/o24/OvfVlvJVDhwxM H7MqCQ+GKW6aBd/mynSdogRmDeaKasf2BuLlMeNOdfsXLUProJCjXvevFoS5welicDPm 58YWEs5P2DCL8wXpYU9StF6X1BmzfCRTqKbjC6cOZd4kuHQQL+qhX9GSv7cx2B7Voh/K Aj8TFLt6ii6g70GXdGKirCpX3e/l2oia1cCOWsu9ueo1Aoviohht+mbY/7D5I9Sbecws Wi1yQWztUIjQM1thq62crXAqchWRW+XvnzeILY5I+Yx1SR3W9Obiw2Mw/bFJdtw1SdqH /Ybw== X-Gm-Message-State: AGi0PubLPQAphZRPd2WcauvtfNRXvWVBvbWT+Fdhdix6cnvZjy019rd1 1+y2On7KdMQjr5+ejv97tn4= X-Received: by 2002:a17:90a:faa:: with SMTP id 39mr20560705pjz.190.1586073091494; Sun, 05 Apr 2020 00:51:31 -0700 (PDT) Received: from localhost (n112120135125.netvigator.com. [112.120.135.125]) by smtp.gmail.com with ESMTPSA id p7sm9510970pjp.1.2020.04.05.00.51.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Apr 2020 00:51:30 -0700 (PDT) From: Qiujun Huang To: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.a, tglx@linutronix.de Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Qiujun Huang Subject: [PATCH] powerpc/powernv: add NULL check after kzalloc in opal_add_one_export Date: Sun, 5 Apr 2020 15:51:23 +0800 Message-Id: <20200405075123.28756-1-hqjagain@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/platforms/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 *parent, const char *export_name, goto out; attr = kzalloc(sizeof(*attr), GFP_KERNEL); + if (!attr) { + rc = -ENOMEM; + goto out; + } + name = kstrdup(export_name, GFP_KERNEL); if (!name) { rc = -ENOMEM; -- 2.17.1