Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2352642ybb; Sun, 5 Apr 2020 05:28:00 -0700 (PDT) X-Google-Smtp-Source: APiQypJ9xtSNZOVRD3E9yDrYGkhZRoySslEOn7vLjrsnctln2B3/ZDSN0FP/D1AOyUKLs4nxFRwG X-Received: by 2002:a05:6830:22d9:: with SMTP id q25mr13146480otc.164.1586089680573; Sun, 05 Apr 2020 05:28:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586089680; cv=none; d=google.com; s=arc-20160816; b=pTsHnvoqfrDGvovFt1emqjRHfGpM1JwNcD5F9Y9j+4kDspbQRhNLP1tIVzGTqKpzBt XsyBotlTYAyqdvqJsVLpqLpc19nFWUg3RyxJcQVTNG8C+HDRsbZg4s5SUatlwBk7lTQF lQ0bi7RLC2m37Evt6neNy00zMFTBKP9DGNijLtzQqrotzXhxIBWuuDAzPXyOrbjlvkbS GS6+uTA3/iu4wwEAL5/luEH4AnZm6Tx4VWmLFBBgb3RDt4R2YfRNz3+1JDN9U6tXznWD 4y7JQsGFZ2Nof4mm9QG5KS/0NRSRwXzLOaPUku/UJqCyzOeEWQvCG0kdhDzhBrZMtaxV 4ESQ== 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=mblZgCC2Cl9506DCpo/VF03PoaE1EG2NCS/yPRhOyVc=; b=CP4+jdzt7ykGUp4WO3RIjkqCgrZubLg/nAOLyORM1KfmtIBHyLLgwj4pcOfPvYfHXx vE5XEjyKKb/qMYRJWQeN5JTaqojO5+PWmwUyAWNQI/XfPbYxp0L7n4Yvx/oVbo/vshra ZZuX4lAu0z6tXRVVlA7iQo0om1A2bVU5SN+soyrVrxc62hpGBW+ZrP2MeJf6r8Vtc9Ct F8rgDr7okFa/FyZzF/Ehmi3ItlE3Tjac74OtOmkl47HYdP/KcI9xWGsMujgwJY80HVKo qwqHMNB874YQyqjCaFE+XTfsyYYTXGltYNVHM2j0u+AGuE7+J7GUgRR5hHPBYwQLRIT4 ++LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fJ1ZlYHp; 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 z126si5874266oia.187.2020.04.05.05.27.47; Sun, 05 Apr 2020 05:28:00 -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=fJ1ZlYHp; 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 S1726659AbgDEM0B (ORCPT + 99 others); Sun, 5 Apr 2020 08:26:01 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:41884 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726388AbgDEM0B (ORCPT ); Sun, 5 Apr 2020 08:26:01 -0400 Received: by mail-pf1-f194.google.com with SMTP id a24so6137253pfc.8 for ; Sun, 05 Apr 2020 05:26:00 -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=mblZgCC2Cl9506DCpo/VF03PoaE1EG2NCS/yPRhOyVc=; b=fJ1ZlYHpiC1YETL+MpOGOhen2lYkAFpSNfdQwn56F/eqWl78ShJ75UG0vPwAkNPc7s mc9AJlqmcXOZBeizj1v96RTUf6bBBK7mNOGdrbqJZvLxW5SH6xknxnCA1FANunKiaz36 bnzCsHHXBoiFUEt/ZyJTf6IOqhGfimvXGwnpCyyLvNVarMYxAbKAaeev+qlmPsCRrRRL 2zo7VwFeulBDRK4v4iealA/UEJIjAWsrBcXWUhQcOyFQQdOaFNVaTe0l/7MC8sqdbO8E QDMtTY7/lXbszNk16igin42MJeruNb2M0xsvix8XEZZpbjpt3e6ENpGtc7g8y09f1KxM 0Pqg== 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=mblZgCC2Cl9506DCpo/VF03PoaE1EG2NCS/yPRhOyVc=; b=CgG74dumKqMyP6x7L/suNT9HaUsKZaP4eRixBxnfIAb0D1oPRNYVigahpeyde6Darh D0QIT1yL8lXQ4gx6P2gHhGNSimcc867nGntr9zU2MvYsTIjJp1FsB4Mm1BsWtU1WinPm +NATIuZzwOe9nWpMwpxCxDrxuYJ/cPB3wFhclBZLJvHerXJkgpwKJXZAMnBPT+koFQ9s rTS7/7Jcalb+Bog/N/gs+8wjPLRCTrj//kajkQ9+oB8x6SDvR95gB0t+Xd6YIt8zJWD3 CblrLH0P1rLa34U82fk9C7fwXiAcSbLzT3aBoqVMAJhe8jVRjUHRxAe430bnbLbPY/FU TdFQ== X-Gm-Message-State: AGi0PuafzjjEK9SJSK4W1pVLlUsWkfb1NG9QOPkioEaKUzlVR/RVnU+E limjpbtuKerrBeRO5uTOUk0aA7OV X-Received: by 2002:a63:7a49:: with SMTP id j9mr16094104pgn.183.1586089560133; Sun, 05 Apr 2020 05:26:00 -0700 (PDT) Received: from localhost (n112120135125.netvigator.com. [112.120.135.125]) by smtp.gmail.com with ESMTPSA id n100sm9561716pjc.38.2020.04.05.05.25.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 Apr 2020 05:25:59 -0700 (PDT) From: Qiujun Huang To: 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, christophe.leroy@c-s.fr, Qiujun Huang Subject: [PATCH v3] powerpc/powernv: add NULL check after kzalloc in opal_add_one_export Date: Sun, 5 Apr 2020 20:25:54 +0800 Message-Id: <20200405122554.357-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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index 2b3dfd0b6cdd..908d749bcef5 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c @@ -801,16 +801,19 @@ static ssize_t export_attr_read(struct file *fp, struct kobject *kobj, static int opal_add_one_export(struct kobject *parent, const char *export_name, struct device_node *np, const char *prop_name) { - struct bin_attribute *attr = NULL; - const char *name = NULL; + struct bin_attribute *attr; + const char *name; u64 vals[2]; int rc; rc = of_property_read_u64_array(np, prop_name, &vals[0], 2); if (rc) - goto out; + return rc; attr = kzalloc(sizeof(*attr), GFP_KERNEL); + if (!attr) + return -ENOMEM; + name = kstrdup(export_name, GFP_KERNEL); if (!name) { rc = -ENOMEM; -- 2.17.1