Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5708674yba; Thu, 11 Apr 2019 04:12:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJPlofr9LxtStl1PVK50l9ApBJ/jB3cmWP4xYETCoPtvVyCqqVYDf7Be+A9rBFJsmXGzU1 X-Received: by 2002:a63:8548:: with SMTP id u69mr47130306pgd.85.1554981127405; Thu, 11 Apr 2019 04:12:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554981127; cv=none; d=google.com; s=arc-20160816; b=yaxBtyUmUcrb7hurycSaEPs3SQqLHnQZyXNzZq5Z1I3V3ujOUyoFly7Ha/637RMrZh HZF7mDsoTJ6pYYDXhM66F2Fy6Khb1/DXcUaS9mSP950Rok0bjYV4E9A6qF9F2Po16K5m t54wcC5gN3SLjf4Ts1JWtEN7cowunTzmklLl3bhi4JNzbxaV0V9ioCvHRxPeRHuFaSxK hEt6jvHI4ovUy2lB8fSn6OZxrz8Z4UCf1nFO7ZulCYeA9zNwbQR6xvGNYLwDVqgz6mTb N0n78KYwNUKZVYIIb7DVwYdJ1cfsuNvLkYy7TZPiQrbkS9ipIGCbgWleMm/KHQszCAfR EEeA== 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 :message-id:date:subject:cc:to:from; bh=I/kmvnWPqGwhEx/wx0Tfdw8YtCd3PF0otIwlvdQzFyU=; b=JIixTsFo3D8ovmc//XzijETbwX98HmuCtPPEkXrqZj050wWj5DXwx6fHiRHxeeHiC6 qSg/5mgQdbfx888gPr0GS5Ld8wgsapvdkmLAWeiRfVDArRSUpW3RhhQkLUYXFAcu8x8l DjLPUrQ8hDepKKSvJj4q9AfxpHmIIsBigw46qFK4XfEcAFYfG7xSvtMm0MQGP4KMIhji xNo6Ih60ggtr/AfxAe0tWb0znvjfi4mUDml3ietSU1txFgEe5aqOrUizETd8My7sZeCn Q/uhK/u6HXiWTMFFBVBCJ/s2GxPG1qETm/lZpnRwDaCZ40y+BMwX4ZE5uJqV7zmKiAXf bmnQ== 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 m4si3023874plt.26.2019.04.11.04.11.51; Thu, 11 Apr 2019 04:12: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; 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 S1726713AbfDKLKC (ORCPT + 99 others); Thu, 11 Apr 2019 07:10:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52592 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726121AbfDKLKC (ORCPT ); Thu, 11 Apr 2019 07:10:02 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D472D77F2; Thu, 11 Apr 2019 11:10:01 +0000 (UTC) Received: from t460s.redhat.com (unknown [10.36.118.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id B657660BF7; Thu, 11 Apr 2019 11:09:56 +0000 (UTC) From: David Hildenbrand To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, David Hildenbrand , Andrew Morton , Oscar Salvador , Michal Hocko , Pavel Tatashin , Wei Yang , Qian Cai , Arun KS , Mathieu Malaterre Subject: [PATCH v2] mm/memory_hotplug: Drop memory device reference after find_memory_block() Date: Thu, 11 Apr 2019 13:09:55 +0200 Message-Id: <20190411110955.1430-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 11 Apr 2019 11:10:01 +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