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
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]>
  • Loading branch information
Ma Ke authored and Paolo Abeni committed Jun 27, 2024
1 parent 3f4d9e4 commit 1864b82
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 @@ -2798,6 +2798,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 1864b82

Please sign in to comment.