Commit c4ea7d8
net: mana: fix use-after-free in add_adev() error path
If auxiliary_device_add() fails, add_adev() jumps to add_fail and calls
auxiliary_device_uninit(adev).
The auxiliary device has its release callback set to adev_release(),
which frees the containing struct mana_adev. Since adev is embedded in
struct mana_adev, the subsequent fall-through to init_fail and access
to adev->id may result in a use-after-free.
Fix this by saving the allocated auxiliary device id in a local
variable before calling auxiliary_device_add(), and use that saved id
in the cleanup path after auxiliary_device_uninit().
Fixes: a69839d ("net: mana: Add support for auxiliary device")
Cc: [email protected]
Reviewed-by: Long Li <[email protected]>
Signed-off-by: Guangshuo Li <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>1 parent 815980f commit c4ea7d8
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3425 | 3425 | | |
3426 | 3426 | | |
3427 | 3427 | | |
| 3428 | + | |
3428 | 3429 | | |
3429 | 3430 | | |
3430 | 3431 | | |
| |||
3434 | 3435 | | |
3435 | 3436 | | |
3436 | 3437 | | |
3437 | | - | |
| 3438 | + | |
| 3439 | + | |
3438 | 3440 | | |
3439 | 3441 | | |
3440 | 3442 | | |
| |||
3460 | 3462 | | |
3461 | 3463 | | |
3462 | 3464 | | |
3463 | | - | |
| 3465 | + | |
3464 | 3466 | | |
3465 | 3467 | | |
3466 | 3468 | | |
| |||
0 commit comments