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 383FB2877F7; Thu, 25 Jun 2026 13:12:44 +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=1782393165; cv=none; b=oMpbSEBkyuwpW2wYQGGv4hVMhKEE4aLZ9r430opCFo+TIRDUShTJC0VRCLOPTD6Im1l780KIYIUS4/Bs54dPwIbav6/LP5Autg2s/5zVhh1o9fujVZxJ8ioUY0xyzTGEWOP6aVp9MfToNozIy8J2sIDTxcwOX6ZhJWIrXHtkEww= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782393165; c=relaxed/simple; bh=4cdVUWQlZH+WnWAsco7BUQCMJKNXlP65nwzZLhP2dFQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ebRusm3TvNFh+6N4I5+/PYEhIbYqnBn5ny/rAijyjMzUTT+qCa0M3XPExqtTQZCeLCOnatEgkwYVvr7HiEwEc54v85S21UxQ7IBtcWTQTmCBVLpzgF20mwuD+VDTDncyU2PkKFNSsfMC8UbA/hKDKn3FU+24MIfH1rGFmf/TIng= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=I4CThmsr; 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="I4CThmsr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 863A51F000E9; Thu, 25 Jun 2026 13:12:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1782393164; bh=EorIz7hdLFGcmSan6qIqqexDAsxq3nuzk62tVrXpDek=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=I4CThmsrD94nP+lSCN1jSh6p/55XioaGCud+B3JOYqOuhpwmQQIi71hX6xs6ZI9pK tCp8h6RKRH9dy+ED2JtnV+GmBAvBbCanGfmxDHP/Iw6vSE+FiRx0MFx50jOwODZ3O7 ruLqwT3uMXrhspTA9rjtWRnm79bSi2w5AehoLzH4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Georgi Djakov , "Oscar Salvador (SUSE)" , Vishal Verma , Mike Rapoport , Richard Cheng , David Hildenbrand , Georgi Djakov , "Rafael J. Wysocki" , Andrew Morton Subject: [PATCH 7.1 18/21] drivers/base/memory: set mem->altmap after successful device registration Date: Thu, 25 Jun 2026 14:04:10 +0100 Message-ID: <20260625125615.787752731@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260625125613.243729608@linuxfoundation.org> References: <20260625125613.243729608@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Georgi Djakov commit a2b8d7827f48ee54a686cb80e4a1d0ff954ec42a upstream. If __add_memory_block() fails at xa_store() (under memory pressure for example), device_unregister() is called, which eventually triggers memory_block_release() with mem->altmap still set, causing a WARN_ON(mem->altmap). This was triggered by modifying virtio-mem driver. Fix this by delaying the assignment of mem->altmap until after __add_memory_block() has succeeded. Link: https://lore.kernel.org/20260514092657.3057141-1-georgi.djakov@oss.qualcomm.com Fixes: 1a8c64e11043 ("mm/memory_hotplug: embed vmem_altmap details in memory block") Signed-off-by: Georgi Djakov Acked-by: Oscar Salvador (SUSE) Cc: Vishal Verma Cc: Mike Rapoport Cc: Richard Cheng Cc: David Hildenbrand Cc: Georgi Djakov Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- drivers/base/memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -807,7 +807,6 @@ static int add_memory_block(unsigned lon mem->start_section_nr = block_id * sections_per_block; mem->state = state; mem->nid = nid; - mem->altmap = altmap; INIT_LIST_HEAD(&mem->group_next); #ifndef CONFIG_NUMA @@ -825,6 +824,8 @@ static int add_memory_block(unsigned lon if (ret) return ret; + mem->altmap = altmap; + if (group) { mem->group = group; list_add(&mem->group_next, &group->memory_blocks);