From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 35ED8279903; Thu, 28 May 2026 20:16:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779999384; cv=none; b=LXYtZYEfcJDLR/mMjxdtMdZMHdxuf2c9CTPqrM7r8GnJWFUKYNeQ8Fv9Kr+DtmT0zLdb8gE7I492YpOoTeN68OyeA+cktu+zXDY1m7ooBQnYj+gdvnZp8rdD04COx5CRZ4cGGVE83xbUUVHkVNHAvSHuM+igHJhr17W9hcmGXkQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779999384; c=relaxed/simple; bh=Qm3Wvl1phwBBFvcEnbOJIj+obiWAxZtHXga+HfJFj0Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gI42EGjroc1auW9SyN3xG4J7EPH4IByjkEvWTxGW2/hsQkypbiul7iabNhyf4XKnjGuW0pXGj0GqOESIPj7rUs/T7qTFiVyG95EmwPfQajBETWmc52eJH+2KQI1yMJonvYvSWC590KGGk5qwyZ5OyHyaY/isVIxDEAYyUg+loL8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=C01nKZp1; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="C01nKZp1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90F2C1F000E9; Thu, 28 May 2026 20:16:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1779999383; bh=QF1cAjdNwqk1s3lNYj/OAPwuLrLBX8k2L7sbbe7F7GI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=C01nKZp1wfnX4HMPaRm3ywYEs6WttmrhP43I8UMK7gyIawXIYwnYyU7QHVCEsePCT LP1OUECjieX65S/BZBwdmqbkz4P0u3yiccG/pJo+zPi7mGIe+DPj+t5pVdQVTwi/En hngR03RkT0l7Bgu8KyzEYXz9JtdeREzCmR9MZDjc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Muchun Song , Oscar Salvador , "David Hildenbrand (Arm)" , Danilo Krummrich , "Huang, Ying" , Miaohe Lin , Naoya Horiguchi , "Rafael J. Wysocki" , Vishal Verma , Andrew Morton Subject: [PATCH 6.18 048/377] mm/memory_hotplug: fix memory block reference leak on remove Date: Thu, 28 May 2026 21:44:46 +0200 Message-ID: <20260528194639.766474541@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260528194638.371537336@linuxfoundation.org> References: <20260528194638.371537336@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Muchun Song commit 93866f55f7e292fe3d47d36c9efe5ee10213a06b upstream. Patch series "mm: Fix memory block leaks and locking", v2. This series fixes two memory block device reference leaks and one locking issue around the per-memory_block hwpoison counter. This patch (of 2): remove_memory_blocks_and_altmaps() looks up each memory block with find_memory_block(), which acquires a reference to the memory block device. That reference is never dropped on this path, resulting in a leaked device reference when removing memory blocks and their altmaps. Drop the reference after retrieving mem->altmap and clearing mem->altmap, before removing the memory block device. Link: https://lore.kernel.org/20260428085219.1316047-1-songmuchun@bytedance.com Link: https://lore.kernel.org/20260428085219.1316047-2-songmuchun@bytedance.com Fixes: 6b8f0798b85a ("mm/memory_hotplug: split memmap_on_memory requests across memblocks") Signed-off-by: Muchun Song Acked-by: Oscar Salvador Acked-by: David Hildenbrand (Arm) Cc: Danilo Krummrich Cc: Greg Kroah-Hartman Cc: "Huang, Ying" Cc: Miaohe Lin Cc: Naoya Horiguchi Cc: "Rafael J. Wysocki" Cc: Vishal Verma Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/memory_hotplug.c | 2 ++ 1 file changed, 2 insertions(+) --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1439,6 +1439,8 @@ static void remove_memory_blocks_and_alt altmap = mem->altmap; mem->altmap = NULL; + /* drop the ref. we got via find_memory_block() */ + put_device(&mem->dev); remove_memory_block_devices(cur_start, memblock_size);