Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp489626yba; Wed, 15 May 2019 05:04:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBKOrcL3zdjbB8DBkkpU3N5iJlAUWGcczaAXhUJg0sNWTBiGxLBVWUOCJzvV5OMPbHSoPu X-Received: by 2002:a17:902:7610:: with SMTP id k16mr8098069pll.177.1557921848849; Wed, 15 May 2019 05:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557921848; cv=none; d=google.com; s=arc-20160816; b=KSFyL7jCm42cgyUX4z50ph9cCHWtuBW+JAXHFYV9gDqBRubPCTbjRwEpeVm8iPdU9l gI3b6cWpGdVR+ftG9G4CEUH0cTWwiwz1/JccE5nD7KLB9yaLk1It0LW5u2HcehfGtM/f GSjqqyAv6EInTaKwpnr/5vEqs1Bjd6K6f87PljxN1iridRiqmh35nalw9KsHDLDA3tbT G/0a46BIINnkD6pccqobySFTu8kBAmXVeReT9M5s3DiD46mcyY5I477E/suOmRYu0iVG vlWNaJtATHKlKM6fEWDjn/MxxhX30aoolE+Cu4xpjrqt6LHKiiEPJGFV0N1DyxeOUGYU y1Ag== 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=ZL4IN6oHj/DiPeWXQjwPzDg56jS7IuTV9iC7HhEGbdo=; b=oD29bUI9RTMr63wXy7ddlrC51j8uci2qhRHU8eKO9CKC/et3LR44zSIiiir0HZpLjQ Ug8k0D5XIBB/QpoktOhNVpcRl4t9/bxOyqlNelWDsBb94zJ69pfDZ/M7ekEsXeePDyLM daV6sll5Ualf2WFfCXV835GxP95Ox/cpQ5aYPRQBB8AKRe0VjGJARZTdfA8LLZImb3eN dsBWdvwdGerzwJ+LpwUUydsuLRPF0+XaF3vHD+5xy3Up+gK9f1Jme3yhxRcVZPL0mSQv au6sOwpzCIPPih/kyly1ePoEmdRWuUrH2TGzS4qkajJxlWMGvIcGTThfng08KVkEMgNY +hrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mW7VAdvs; 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 j1si1565015pld.399.2019.05.15.05.03.53; Wed, 15 May 2019 05:04:08 -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=mW7VAdvs; 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 S1729707AbfEOMAs (ORCPT + 99 others); Wed, 15 May 2019 08:00:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:50586 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729914AbfEOLO3 (ORCPT ); Wed, 15 May 2019 07:14:29 -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 A15F1216FD; Wed, 15 May 2019 11:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557918869; bh=KRNbchKjvaq9cxfAHE0Ungleyk2I7CgG96cii6I6HJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mW7VAdvsLLGqf1MIuw4DSYHgJ0VYiZQyP4YvG+W6EAEuwtJvjOmK3FR3Aj7BZJ4GA umxDNFLpftAsgFiYdEOMgHOuyV5HcMUOtYiAF5A0/+lrA045oCqmgkb4vZkHYkzaST wjhy/OmpQBTCYsMwI/xpVFJE8ifH5NvcmAK3fqF4= 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 4.9 07/51] libnvdimm/namespace: Fix a potential NULL pointer dereference Date: Wed, 15 May 2019 12:55:42 +0200 Message-Id: <20190515090619.522764942@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090616.669619870@linuxfoundation.org> References: <20190515090616.669619870@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 9bc5f555ee686..cf4a90b50f8b8 100644 --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -2028,9 +2028,12 @@ 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