Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp471083yba; Wed, 15 May 2019 04:43:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTxPblaaH9+h8U7wqokEcVMS/oNSfASAEy2ujMoZItEOzFs6Top0jGnc/dn/8iUziV6xxS X-Received: by 2002:aa7:87ca:: with SMTP id i10mr20436696pfo.157.1557920583909; Wed, 15 May 2019 04:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557920583; cv=none; d=google.com; s=arc-20160816; b=BajobdIT1KTnFl4jd5wLAxe3/AlnPHLoWawbq0lyefWc0fxWzS1lIMtEDtFy4QzPzl R/uAPiqYkkAiixnorUeXQthEO6yWGoOGQvS5BONclPs5ZJafeAE0ZL2mFpP2cFh5lbbp Y1eUMW2AHkiRi38JgauysoxemZQDe6mNdo6jS2GMttXf4tsVKipO81qskyH5qTj+oo9w YjqSWqSeyU6BxODXF2vlcQdKdjTjbBYnCB+SGwzUuzL7X2GE7i2B2aDcoYvTLPijOKQH lZklBF5pDl9GXXS4VJtYYQamyNx2fx405NI8yEz/kKpSJWw1PMZpDWMDEazdS7DvmM34 nQYg== 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=Tz2vRZKETg7I1Rd/w0zfsWmY8um4srmznaPKaAlX7dQ=; b=dtSYNdAm0B6l1lzqcEf5WSBo7lf2v3UQM9OQ/a5CjxgbRVTDClmviQCMsjuvikLosO MSgqpfl+/EY+0vurQ1NnW3ufUqKkR9MmmVMAdUVw5OFR0QaA8Gql4ZIeYI/2WaR6O53v uaSdsxE49kUaH5xLop1rPCWLjFpJa/PgijP0PU9Q98metWgOWEtqYetGCDcyDlwLFYEM pSMxUVUBZQ9buSWh/aT6jEPk/uTXSaeDBBxvcVNfnPEtVO+cIP7Z4LN1AyLpqqg2GihY VkfDNhvlCrjePuJSDSvouAakRdZhk830pW+frFqpIE4GHafOdalRZSfBbUo1eRSOVnsY tAuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pbj9TE7r; 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 d20si1113901pgv.102.2019.05.15.04.42.49; Wed, 15 May 2019 04:43:03 -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=pbj9TE7r; 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 S1732643AbfEOLaA (ORCPT + 99 others); Wed, 15 May 2019 07:30:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:41252 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732170AbfEOL3w (ORCPT ); Wed, 15 May 2019 07:29:52 -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 109A72089E; Wed, 15 May 2019 11:29:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557919791; bh=4qey7BEirvvuZtcb0Q9zTx7XfYJvoEad57AKvq0X7uA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pbj9TE7rkz4MFzvr82qW61VUrHWhAjAVyjCq1tsiXLLdMp27bcVXa6zz+p+qnGgA0 g8XvZ9dRQpMqbzXFxE+nDyOvxuzbYWn77SBQtFp+jPLdvpwwm4ZTmtpy8Jzhn9YrQ1 oAXQvi3UAQDEtyAk9yAEKqZDCODQIIrVysbGfjP0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Hildenbrand , Oscar Salvador , Wei Yang , Michal Hocko , Pankaj Gupta , Pavel Tatashin , Qian Cai , Arun KS , Mathieu Malaterre , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.0 095/137] mm/memory_hotplug.c: drop memory device reference after find_memory_block() Date: Wed, 15 May 2019 12:56:16 +0200 Message-Id: <20190515090700.430914342@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 89c02e69fc5245f8a2f34b58b42d43a737af1a5e ] Right now we are using find_memory_block() to get the node id for the pfn range to online. We are missing to drop a reference to the memory block device. While the device still gets unregistered via device_unregister(), resulting in no user visible problem, the device is never released via device_release(), resulting in a memory leak. Fix that by properly using a put_device(). Link: http://lkml.kernel.org/r/20190411110955.1430-1-david@redhat.com Fixes: d0dc12e86b31 ("mm/memory_hotplug: optimize memory hotplug") Signed-off-by: David Hildenbrand Reviewed-by: Oscar Salvador Reviewed-by: Wei Yang Acked-by: Michal Hocko Acked-by: Pankaj Gupta Cc: David Hildenbrand Cc: Pavel Tatashin Cc: Qian Cai Cc: Arun KS Cc: Mathieu Malaterre Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/memory_hotplug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 11593a03c051f..7493f50ee8800 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -858,6 +858,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ */ mem = find_memory_block(__pfn_to_section(pfn)); nid = mem->nid; + put_device(&mem->dev); /* associate pfn range with the zone */ zone = move_pfn_range(online_type, nid, pfn, nr_pages); -- 2.20.1