]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
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)
committerSasha Levin <sashal@kernel.org>
Fri, 15 Mar 2024 14:48:21 +0000 (10:48 -0400)
commit995f802abff209514ac2ee03b96224237646cec3
tree22a3285c78a6300649e65456fff5f1678ec1898f
parent34cab94f7473e7b09f5205d4583fb5096cb63b5b
net: pds_core: Fix possible double free in error handling path

[ Upstream commit ba18deddd6d502da71fd6b6143c53042271b82bd ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/amd/pds_core/auxbus.c