]> 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:22 +0000 (10:48 -0400)
commitffda0e962f270b3ec937660afd15b685263232d3
treeff8c54e8035ea7603e74be24abbe3b26e3c7e81b
parent16d71319e29d5825ab53f263b59fdd8dc2d60ad4
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