Skip to content

Commit 50271d7

Browse files
Erni Sri Satya VennelaPaolo Abeni
authored andcommitted
net: mana: Guard mana_remove against double invocation
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: 635096a ("net: mana: Support hibernation and kexec") Signed-off-by: Erni Sri Satya Vennela <ernis@linux.microsoft.com> Link: https://patch.msgid.link/20260420124741.1056179-4-ernis@linux.microsoft.com Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 6e8bc03 commit 50271d7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/net/ethernet/microsoft/mana/mana_en.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3731,11 +3731,16 @@ void mana_remove(struct gdma_dev *gd, bool suspending)
37313731
struct gdma_context *gc = gd->gdma_context;
37323732
struct mana_context *ac = gd->driver_data;
37333733
struct mana_port_context *apc;
3734-
struct device *dev = gc->dev;
3734+
struct device *dev;
37353735
struct net_device *ndev;
37363736
int err;
37373737
int i;
37383738

3739+
if (!gc || !ac)
3740+
return;
3741+
3742+
dev = gc->dev;
3743+
37393744
disable_work_sync(&ac->link_change_work);
37403745
cancel_delayed_work_sync(&ac->gf_stats_work);
37413746

0 commit comments

Comments
 (0)