Skip to content

Commit

Permalink
net: mana: Fix possible double free in error handling path
Browse files Browse the repository at this point in the history
[ Upstream commit 1864b8224195d0e43ddb92a8151f54f6562090cc ]

When auxiliary_device_add() returns error and then calls
auxiliary_device_uninit(), callback function adev_release
calls kfree(madev). We shouldn't call kfree(madev) again
in the error handling path. Set 'madev' to NULL.

Fixes: a69839d ("net: mana: Add support for auxiliary device")
Signed-off-by: Ma Ke <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: August <[email protected]>
  • Loading branch information
Ma Ke authored and Dangku committed Aug 7, 2024
1 parent a95b81d commit 00aa441
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/net/ethernet/microsoft/mana/mana_en.c
Original file line number Diff line number Diff line change
Expand Up @@ -2752,6 +2752,8 @@ static int add_adev(struct gdma_dev *gd)
if (ret)
goto init_fail;

/* madev is owned by the auxiliary device */
madev = NULL;
ret = auxiliary_device_add(adev);
if (ret)
goto add_fail;
Expand Down

0 comments on commit 00aa441

Please sign in to comment.