net: pds_core: Fix possible double free in error handling path
authorYongzhi Liu <hyperlyzcs@gmail.com>
Wed, 6 Mar 2024 10:57:14 +0000 (18:57 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 7 Mar 2024 11:03:19 +0000 (12:03 +0100)
commitba18deddd6d502da71fd6b6143c53042271b82bd
tree00ceb6ab7fb3cea66ace3e939d862e15f79ef9f9
parentd5b8aff73d159b9157db0ad3281a9af3185d59fa
net: pds_core: Fix possible double free in error handling path

When auxiliary_device_add() returns error and then calls
auxiliary_device_uninit(), Callback function pdsc_auxbus_dev_release
calls kfree(padev) to free memory. We shouldn't call kfree(padev)
again in the error handling path.

Fix this by cleaning up the redundant kfree() and putting
the error handling back to where the errors happened.

Fixes: 4569cce43bc6 ("pds_core: add auxiliary_bus devices")
Signed-off-by: Yongzhi Liu <hyperlyzcs@gmail.com>
Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com>
Reviewed-by: Shannon Nelson <shannon.nelson@amd.com>
Link: https://lore.kernel.org/r/20240306105714.20597-1-hyperlyzcs@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/amd/pds_core/auxbus.c