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 DB91F36B93B; Sat, 17 Oct 2026 16:21:25 +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=1792254086; cv=none; b=sfSYvZR3c0vM24YB9g2yg2TQqwiLt+ORMGD38Q+9mWDMgu0+0yMuzAt7ktv7hUhu1q5j2e9WWrNJaGbsGHzr5gJJe46OmRxIGaInXS9rsfLTbVi9oUpyPpqtfkX09Z97ldy7sC2HT6FrQIGj73LLWbYVubmA+mDFtxQVFPNiQQ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792254086; c=relaxed/simple; bh=7SeTzYrj0jyNg+5DBQdQfYNI6dxu3m8g5XS99BA/qic=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dO92Ecllo9DicPSkWs6NesjsWAX37Q79Ml3JeveEbZlnACHaQ16KvJWOhbQ7+L2Wcf9WBSqPDzoAxbo9u6Ogt/oO0JUAIJ0zkxCYaRWP10Gi10S0E+P7QOuo91SniIKgFeXYwn4s1UEKNogPLW+zg3venf8qEY7+y+jBBHjK9Qs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MwEkCCQb; 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="MwEkCCQb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 304391F000C4; Sat, 17 Oct 2026 16:21:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792254085; bh=0GIPwo4dmYYH95QvyJMjQJphMio8mX4WZ6u9+quNASc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MwEkCCQbVyNhaw0cT7j75TOhR2LgOwjuenWLMsuZh+zsH0Ro9euUF2up8eBuX/AhV CE8hCYexMkNkrRjVe1Sg1SrjIvNIep5RcpVdaCyH4OlO/A6aoUodb/ZVLmkLqIyDpk Bdt2CvBpP+avQQX/rzddk+SIlfwnckHBGT5XEz34= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Erni Sri Satya Vennela , Simon Horman , Paolo Abeni , Sasha Levin Subject: [PATCH 6.12 329/869] net: mana: Guard mana_remove against double invocation Date: Sat, 17 Oct 2026 17:52:50 +0200 Message-ID: <20261017160045.514261282@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261017160036.979869304@linuxfoundation.org> References: <20261017160036.979869304@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 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Erni Sri Satya Vennela [ Upstream commit 50271d7ec95144d26808025b508f463780517d3c ] If PM resume fails (e.g., mana_attach() returns an error), mana_probe() calls mana_remove(), which tears down the device and sets gd->gdma_context = NULL and gd->driver_data = NULL. However, a failed resume callback does not automatically unbind the driver. When the device is eventually unbound, mana_remove() is invoked a second time. Without a NULL check, it dereferences gc->dev with gc == NULL, causing a kernel panic. Add an early return if gdma_context or driver_data is NULL so the second invocation is harmless. Move the dev = gc->dev assignment after the guard so it cannot dereference NULL. Fixes: 635096a86edb ("net: mana: Support hibernation and kexec") Signed-off-by: Erni Sri Satya Vennela Link: https://patch.msgid.link/20260420124741.1056179-4-ernis@linux.microsoft.com Reviewed-by: Simon Horman Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- drivers/net/ethernet/microsoft/mana/mana_en.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index bd1ae41df552d..ef89f3e06a265 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -3006,11 +3006,16 @@ void mana_remove(struct gdma_dev *gd, bool suspending) struct gdma_context *gc = gd->gdma_context; struct mana_context *ac = gd->driver_data; struct mana_port_context *apc; - struct device *dev = gc->dev; + struct device *dev; struct net_device *ndev; int err; int i; + if (!gc || !ac) + return; + + dev = gc->dev; + /* adev currently doesn't support suspending, always remove it */ if (gd->adev) remove_adev(gd); -- 2.53.0