Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7545746yba; Thu, 2 May 2019 11:45:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYMl7XeKn8z8j9XdmPPeys+NWb/gWeEMV7xbS13Yg1pCRu5sMPbcdfMngZd9ndxMNURdOM X-Received: by 2002:a63:6849:: with SMTP id d70mr5429371pgc.21.1556822759453; Thu, 02 May 2019 11:45:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556822759; cv=none; d=google.com; s=arc-20160816; b=zZA/l4qEe1uHPeeDV7syEqnrs1m3yuYTxeE3wmZO7R0tD16xEDE/O9UV85Sq0gsJXs 33Hk0yPYtpWwdZdgTOw0rIPXRn59Y8ep2QWZWOMt7hnvCE0kXYaesrIXGlt42FP8UVL4 GRCwz/+ZIRBtJ1KcG3hE7W7jMzfrZwCVl7lv28bqxcgda/DuNN4APY52yAJXz1ptBlW/ 6MAbNlgbpS611+EyDrMPOI8QMQoyXwy2u185nr/eElSX73Hf732x8Ou+9n2syDRavmLd vvpcNBBV6hCDA6A3R1uGHpKM+aG8PWzpIHo8EfiJ6jXw4kOlGmMJfCdlkUF2pIMMz68A A7qA== 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 :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=154pK5P8ksWbhOO3IYrUyqpSsi0GfqRRa2gpHRslqUk=; b=IuepDcUVRjVvggXG9DxNC9nb66P/rR8MklSwIFumCnqk9DfsPq35703uu+DKWqL+Th Pw9M39xqo6lccyLqbLAgWTDiaBQ+85KFVAhGYB+AeDek9dfYWNzE4zkiiMEEYtE73zBY jsDrveOYtXUmbrBnMVZwNg/bXPJFNR6bVFez+lQnZ6/wMKB6OVwSdG8g4GI9uPMIZJvX 4DuVmKKGr+vhSsZ07UMqW5bbAr0+2s7V0GND0p6IrlCQp26sk0RFhH/MklR595j478ln AskR6f0hLQ9cd45myYGPrkwVtZMG9bX+k6beSgpRj6GWFmtb84IK4xDNMeZkR9RGYX7v xG5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=Ln6d07+p; 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 k1si41982122pgq.219.2019.05.02.11.45.44; Thu, 02 May 2019 11:45:59 -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=@soleen.com header.s=google header.b=Ln6d07+p; 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 S1726341AbfEBSnp (ORCPT + 99 others); Thu, 2 May 2019 14:43:45 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:37834 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725962AbfEBSnn (ORCPT ); Thu, 2 May 2019 14:43:43 -0400 Received: by mail-qk1-f193.google.com with SMTP id c1so2135487qkk.4 for ; Thu, 02 May 2019 11:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=154pK5P8ksWbhOO3IYrUyqpSsi0GfqRRa2gpHRslqUk=; b=Ln6d07+pCYwbOjMFJVcdvs72qSgpRQCxY10mk5EhNLZCCmdMu75C3Wt5remthzgW67 V4y5TmsCpIkhCATiM5w4PnSDvo+2ad76snqHZ1BlD/WCqdONPaNhAwrZFGW7OAb2V9sj evPR4Ort8jUgIJ58yqKrItZUPn32mS83xIUWpb8GYaC/nJNhKZfZFK2fc9lv+R9s3DTG rK2ZAUdIL3A7/jl4Mu2oUqA6qXaATfKDsG8ix3Umce3pVsoYEm7Xh9DaPp/mD9BhTRUD bFZMZj89CQS8F/ao/RoBvjb13qg+71zc3NWtzG51TmtvQZg+zD8u9n/dnSikt9j6kBv5 Etsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=154pK5P8ksWbhOO3IYrUyqpSsi0GfqRRa2gpHRslqUk=; b=flmsNr1GGl8Fn6NHzruRgRfmMVMTq/0LcOwmYS1cmSkqEdyktMkTl6kYbTKAKVd4P4 y2FDU9tJbgBJxfhnkgfpcKkqeVY1tNddM6pBlkaka0XgctVT5HRxi1iCSImmS5f9ftBN /1xJpELw01NMGPhj/ZkPObj1MMOEi+D1jwNJBQWbC4cTOtCHMhaPJkYGTVr6mGh9oTnt z11eRANhqIbfME51Fs8i4ffZCjV5IGNmb0lUvSAh3n69KSvVU5PpBhVdWDN1BqZYPDjb hpQ2FhMNay5yV/T5emNUG+2eFqx+MAtW8zBG0gArerheRbkTjqo5RugFuNJkJTblsxO4 pNuQ== X-Gm-Message-State: APjAAAXavsg5SeCqwGKltr1iqzoRyfW39+JOH8w3cECg1tM8cVT7oSxv BfTSYc4zm+Q5Vi8L1wFnX4vKOA== X-Received: by 2002:a37:4247:: with SMTP id p68mr2794611qka.89.1556822622604; Thu, 02 May 2019 11:43:42 -0700 (PDT) Received: from localhost.localdomain (c-73-69-118-222.hsd1.nh.comcast.net. [73.69.118.222]) by smtp.gmail.com with ESMTPSA id 8sm25355751qtr.32.2019.05.02.11.43.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 May 2019 11:43:40 -0700 (PDT) From: Pavel Tatashin To: pasha.tatashin@soleen.com, jmorris@namei.org, sashal@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-nvdimm@lists.01.org, akpm@linux-foundation.org, mhocko@suse.com, dave.hansen@linux.intel.com, dan.j.williams@intel.com, keith.busch@intel.com, vishal.l.verma@intel.com, dave.jiang@intel.com, zwisler@kernel.org, thomas.lendacky@amd.com, ying.huang@intel.com, fengguang.wu@intel.com, bp@suse.de, bhelgaas@google.com, baiyaowei@cmss.chinamobile.com, tiwai@suse.de, jglisse@redhat.com, david@redhat.com Subject: [v5 1/3] device-dax: fix memory and resource leak if hotplug fails Date: Thu, 2 May 2019 14:43:35 -0400 Message-Id: <20190502184337.20538-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190502184337.20538-1-pasha.tatashin@soleen.com> References: <20190502184337.20538-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When add_memory() function fails, the resource and the memory should be freed. Fixes: c221c0b0308f ("device-dax: "Hotplug" persistent memory for use like normal RAM") Signed-off-by: Pavel Tatashin Reviewed-by: Dave Hansen --- drivers/dax/kmem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c index a02318c6d28a..4c0131857133 100644 --- a/drivers/dax/kmem.c +++ b/drivers/dax/kmem.c @@ -66,8 +66,11 @@ int dev_dax_kmem_probe(struct device *dev) new_res->name = dev_name(dev); rc = add_memory(numa_node, new_res->start, resource_size(new_res)); - if (rc) + if (rc) { + release_resource(new_res); + kfree(new_res); return rc; + } return 0; } -- 2.21.0