Skip to content
Commit 10eff1f5 authored by Pavel Skripkin's avatar Pavel Skripkin Committed by Jakub Kicinski
Browse files

Revert "net: mdiobus: Fix memory leak in __mdiobus_register"

This reverts commit ab609f25.

This patch is correct in the sense that we _should_ call device_put() in
case of device_register() failure, but the problem in this code is more
vast.

We need to set bus->state to UNMDIOBUS_REGISTERED before calling
device_register() to correctly release the device in mdiobus_free().
This patch prevents us from doing it, since in case of device_register()
failure put_device() will be called 2 times and it will cause UAF or
something else.

Also, Reported-by: tag in revered commit was wrong, since syzbot
reported different leak in same function.

Link: https://lore.kernel.org/netdev/20210928092657.GI2048@kadam/


Acked-by: default avatarYanfei Xu <yanfei.xu@windriver.com>
Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
Link: https://lore.kernel.org/r/f12fb1faa4eccf0f355788225335eb4309ff2599.1633024062.git.paskripkin@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 4de593fb
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment