From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A8AF2BB1D; Sun, 26 Apr 2026 15:17:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777216642; cv=none; b=Zee5hfo2a/LY/UY65AnHt+Cik8wzBjcLVdEkO87wfUkB5t0vmIOPS69w7TGfVxJZzuFKEMB4lxHE268jqU7RtEFIcOt15iY0CIqMqcHC3AIu39tqemjmt+Me65bKND7YmM9419Lfr5665ePmo5X1hTxXkaZv+s295rknNEnKD4E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777216642; c=relaxed/simple; bh=KdfmTbYuWWydQ0mdzrobXnhN26++gmgMuWOa1XZVOU0=; h=Date:To:From:Subject:Message-Id; b=lBH+XKfUrySvDxSbXAhJ5jYxtzjzv4ULrFB8KGiRgwtOv91v0u3JC/lgIl2pz+2pfk8uBjZjzY1AvXZsvDgRMVIWuebdydf3Hgw8avDKnbp22URH0/eXUepguM3yJ7LL0l6q3aTlChjrk/jErgNY/tjx2BHK0L4LIwWHvLzb1+k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=rkuNW/a3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="rkuNW/a3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1AC1C2BCAF; Sun, 26 Apr 2026 15:17:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1777216641; bh=KdfmTbYuWWydQ0mdzrobXnhN26++gmgMuWOa1XZVOU0=; h=Date:To:From:Subject:From; b=rkuNW/a3Xfn67eSVVBvFMrA45wj97llWyaKHU3vJ1VnqDviXiG0IsavjItEbKwAK9 T4RU2ENh7bxyaVWAp047TjaNhMMELYXEh0Q2coY/nPfKz8mhU2c6/S6JbTpMgPhh8V zH6StaRZB2mmiXgi43fiqs8MLtZEXc+MPmbgjMxE= Date: Sun, 26 Apr 2026 08:17:21 -0700 To: mm-commits@vger.kernel.org,vishal.l.verma@intel.com,stable@vger.kernel.org,rafael@kernel.org,osalvador@suse.de,nao.horiguchi@gmail.com,linmiaohe@huawei.com,huang.ying.caritas@gmail.com,gregkh@linuxfoundation.org,david@kernel.org,dakr@kernel.org,songmuchun@bytedance.com,akpm@linux-foundation.org From: Andrew Morton Subject: + drivers-base-memory-fix-memory-block-reference-leak-in-poison-accounting.patch added to mm-hotfixes-unstable branch Message-Id: <20260426151721.A1AC1C2BCAF@smtp.kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The patch titled Subject: drivers/base/memory: fix memory block reference leak in poison accounting has been added to the -mm mm-hotfixes-unstable branch. Its filename is drivers-base-memory-fix-memory-block-reference-leak-in-poison-accounting.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/drivers-base-memory-fix-memory-block-reference-leak-in-poison-accounting.patch This patch will later appear in the mm-hotfixes-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Muchun Song Subject: drivers/base/memory: fix memory block reference leak in poison accounting Date: Sun, 26 Apr 2026 22:44:47 +0800 memblk_nr_poison_inc() and memblk_nr_poison_sub() look up a memory block via find_memory_block_by_id(), which acquires a reference to the memory block device. Both helpers use the returned memory block without dropping that reference, leaking the device reference on each successful lookup. Drop the reference after updating nr_hwpoison. Link: https://lore.kernel.org/20260426144447.817722-2-songmuchun@bytedance.com Fixes: 5033091de814 ("mm/hwpoison: introduce per-memory_block hwpoison counter") Signed-off-by: Muchun Song Cc: Danilo Krummrich Cc: David Hildenbrand Cc: Greg Kroah-Hartman Cc: "Huang, Ying" Cc: Miaohe Lin Cc: Naoya Horiguchi Cc: Oscar Salvador Cc: "Rafael J . Wysocki" Cc: Vishal Verma Cc: Signed-off-by: Andrew Morton --- drivers/base/memory.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/base/memory.c~drivers-base-memory-fix-memory-block-reference-leak-in-poison-accounting +++ a/drivers/base/memory.c @@ -1230,8 +1230,10 @@ void memblk_nr_poison_inc(unsigned long const unsigned long block_id = pfn_to_block_id(pfn); struct memory_block *mem = find_memory_block_by_id(block_id); - if (mem) + if (mem) { atomic_long_inc(&mem->nr_hwpoison); + put_device(&mem->dev); + } } void memblk_nr_poison_sub(unsigned long pfn, long i) @@ -1239,8 +1241,10 @@ void memblk_nr_poison_sub(unsigned long const unsigned long block_id = pfn_to_block_id(pfn); struct memory_block *mem = find_memory_block_by_id(block_id); - if (mem) + if (mem) { atomic_long_sub(i, &mem->nr_hwpoison); + put_device(&mem->dev); + } } static unsigned long memblk_nr_poison(struct memory_block *mem) _ Patches currently in -mm which might be from songmuchun@bytedance.com are mm-memory_hotplug-fix-memory-block-reference-leak-on-remove.patch drivers-base-memory-fix-memory-block-reference-leak-in-poison-accounting.patch mm-sparse-remove-sparse-buffer-pre-allocation-mechanism.patch