Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp473402yba; Wed, 15 May 2019 04:46:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2YzgWx1GdFt0L1Ayid/0KPIBpV26Do4/7P9k21YeSITL2wAftTb9+7LjJBpiUxDxWHftJ X-Received: by 2002:a17:902:7b8d:: with SMTP id w13mr42368784pll.252.1557920767761; Wed, 15 May 2019 04:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557920767; cv=none; d=google.com; s=arc-20160816; b=iT9aond9M8n1lOqtTdp7+6I9qaZ6Egu/xDnWN+b4wFHstQT9TPIXlGeFnrcdlWzSDB +myp4js+pZq/abFjfFmZQiFiHwtmBad0kyqBDblXJMdIt51t+jBgzgh6ap2sZJWqyMyl MVVxqVqFK2hNaO1HOG/jqBLQWfrPS1Sxbm2zJvjkSODPsF77feGlvu9JJ2anaGp4pDm+ dB39GKpS+bsUEudBqwoi6KmqFQaz0jm6Lh22GgHkLtx1xiqtWZDQpshmgY6RQSJkHSiW iP2VOP5x4tOG1+T2dFs6iHeany3Cy9wM7prafBJu3rfa1NQUDyWMSSyxpfTtzaLVRj7w /5bw== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lqM5ULaxM0kJHE+Mqzqu21A2liVRnG1IJWsYepzuWWs=; b=j/7Jrs/lJtm3a4P9ivOSsWuyJJWC/22DMSx2YChQOsFnGPOs6iEJY4e0sq7iRtfr8i sTdc5sWG+GsBOBmDdQAcvB6OH5yvuQVapT/HCnPl8ZSANIP44REhNmATnxDeaS2gSwOO pfegOT2oWOwQgJFkTvvxYfRfz5K5NXljqAuJIz4f2RGtTDsFGAJ26ZyBDagJiDXH+wHx DWj4nACzxXP0NNgGUU+/EH0t3VQl7+B7iNBDyK2RwrXSgRla00GGnowTYHfMukbryXn/ zzkaC9na+k103ylZd/zuB9ZiMT6g83AhXYbR8b58rB7BmBzxfc05JZgJ4NGVL7unpFXz os0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=woX4pzql; 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 m5si1567349pgj.451.2019.05.15.04.45.52; Wed, 15 May 2019 04:46:07 -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=@kernel.org header.s=default header.b=woX4pzql; 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 S1732133AbfEOL0W (ORCPT + 99 others); Wed, 15 May 2019 07:26:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:37126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732119AbfEOL0S (ORCPT ); Wed, 15 May 2019 07:26:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 78E8320818; Wed, 15 May 2019 11:26:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557919578; bh=dD7zTEz88dOfkKYT0g9JV76fjXUG+y9OtNgz7xfOd64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=woX4pzql8RRSu/CLPOj/Qei/7EqnPRn9IyzwVhbA24ufvWrD0VwH4qk1jMlCRfA6A +vOw8NLmyS8eQtotmcYUsxaCnAZlShinEaz26sWPABMO0KWgWiK0EARktUTxscmg2f 2Crz7vXlDWkbc3IurR8tgQO6JCTKFHfJJ/Kw4IQ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kangjie Lu , Dan Williams , Sasha Levin Subject: [PATCH 5.0 015/137] libnvdimm/namespace: Fix a potential NULL pointer dereference Date: Wed, 15 May 2019 12:54:56 +0200 Message-Id: <20190515090654.479892163@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090651.633556783@linuxfoundation.org> References: <20190515090651.633556783@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 55c1fc0af29a6c1b92f217b7eb7581a882e0c07c ] In case kmemdup fails, the fix goes to blk_err to avoid NULL pointer dereference. Signed-off-by: Kangjie Lu Signed-off-by: Dan Williams Signed-off-by: Sasha Levin --- drivers/nvdimm/namespace_devs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c index 33a3b23b3db71..e761b29f71606 100644 --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -2249,9 +2249,12 @@ static struct device *create_namespace_blk(struct nd_region *nd_region, if (!nsblk->uuid) goto blk_err; memcpy(name, nd_label->name, NSLABEL_NAME_LEN); - if (name[0]) + if (name[0]) { nsblk->alt_name = kmemdup(name, NSLABEL_NAME_LEN, GFP_KERNEL); + if (!nsblk->alt_name) + goto blk_err; + } res = nsblk_add_resource(nd_region, ndd, nsblk, __le64_to_cpu(nd_label->dpa)); if (!res) -- 2.20.1