Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5715470yba; Thu, 11 Apr 2019 04:21:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2XTeYJggAiMNP9f189DrnRme1oGcuMwxCB0vtFfav9YensNgZDyAmiIZi9bOKHvnviKVC X-Received: by 2002:a63:e051:: with SMTP id n17mr46464653pgj.19.1554981688163; Thu, 11 Apr 2019 04:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554981688; cv=none; d=google.com; s=arc-20160816; b=OMG1MjZzIh+TkYMOCvtUJRdsXO8r7ZvKQgB12nc9li3QPxGXPFlZA/wv3cycHQFwCx s774MYMMlTBqSi7UNlX1vEc90i5M9nqhSJLOE5gdCKZTjAEa+moomWOtoJDUTheeNhuo /iKN+cS5tHh6c0/CnWXCyeEqKhsApPTM1+dcdhxPY9ojPCAlYavGbZzIhKQVDHABrAIH +Qx5Qmw9r8rcLMv6FZ7ZmkYn88m+ZKXnPPHxvrfWmwJBdvBXzzxxAJBf2HvR7RqjuFMP 5wQp+ZURxpvswcz6Byl2bDrYMTFhokLSKaP8wFNNIrPiJKxenzLjLVR29JmcS0C2an0O qFXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date; bh=gE8DBy8ZknvEWPhXOAMtY9tEqA7/smA66FHYreuujF4=; b=TfN01QW2slr7S9Wu8THdN/kZ5RlLrQ1zMB2ZUvBhIG2Rqh/dUk9yX/LopZtrw4iKTC 51wk1RDbrEo1cIhA5/NlWvoCgjx7HIGS8FThH94e/MRvmEAkHCfi4v/LzYXfAlKf9hpD t5Tvs2wJlvZQzLt4vx1z26A2FT1c7HdLDd8qGC2KetBhwMEG+sFqoa/nyfvmya2pAhCJ SN8Ys+CKWJc/Yi0uW1QLoOzhC8N+II7SS+Mfj9O1TNirtkg+2julAKrQ65UvG7sH5edi NnDqtLgJ7Vo4NQ4e+tqy/s+XWcjdyYbOIMucmyYLoedFbqWBGNtc8gfLfwpzQi+ZQdWI Udkg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 77si22708611pft.72.2019.04.11.04.21.12; Thu, 11 Apr 2019 04:21:28 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726857AbfDKLUK (ORCPT + 99 others); Thu, 11 Apr 2019 07:20:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35432 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726838AbfDKLUJ (ORCPT ); Thu, 11 Apr 2019 07:20:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D483330B4ACF; Thu, 11 Apr 2019 11:20:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C46E65D9C4; Thu, 11 Apr 2019 11:20:08 +0000 (UTC) Received: from zmail21.collab.prod.int.phx2.redhat.com (zmail21.collab.prod.int.phx2.redhat.com [10.5.83.24]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9E2143FAF4; Thu, 11 Apr 2019 11:20:08 +0000 (UTC) Date: Thu, 11 Apr 2019 07:20:08 -0400 (EDT) From: Pankaj Gupta To: David Hildenbrand Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Oscar Salvador , Michal Hocko , Pavel Tatashin , Wei Yang , Qian Cai , Arun KS , Mathieu Malaterre Message-ID: <1160472485.21015333.1554981608278.JavaMail.zimbra@redhat.com> In-Reply-To: <20190411110955.1430-1-david@redhat.com> References: <20190411110955.1430-1-david@redhat.com> Subject: Re: [PATCH v2] mm/memory_hotplug: Drop memory device reference after find_memory_block() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.116.15, 10.4.195.11] Thread-Topic: mm/memory_hotplug: Drop memory device reference after find_memory_block() Thread-Index: hOruerfZeTE3c3BjR0vSDEFOFEFtCw== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 11 Apr 2019 11:20:09 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 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(). > > Fixes: d0dc12e86b31 ("mm/memory_hotplug: optimize memory hotplug") > Cc: Andrew Morton > Cc: Oscar Salvador > Cc: Michal Hocko > Cc: David Hildenbrand > Cc: Pavel Tatashin > Cc: Wei Yang > Cc: Qian Cai > Cc: Arun KS > Cc: Mathieu Malaterre > Reviewed-by: Oscar Salvador > Reviewed-by: Wei Yang > Acked-by: Michal Hocko > Signed-off-by: David Hildenbrand > --- > mm/memory_hotplug.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index 5eb4a4c7c21b..328878b6799d 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -854,6 +854,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 Good catch it is. Acked-by: Pankaj Gupta > >