misc: microchip: pci1xxxx: fix double free in the error handling of gp_aux_bus_probe()
authorYongzhi Liu <hyperlyzcs@gmail.com>
Thu, 23 May 2024 12:14:33 +0000 (20:14 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 4 Jun 2024 16:08:39 +0000 (18:08 +0200)
commit086c6cbcc563c81d55257f9b27e14faf1d0963d3
treec16d5a724ecda82cb024b7cffe4bb00136417e31
parent73fedc31fed38cb6039fd8a7efea1774143b68b0
misc: microchip: pci1xxxx: fix double free in the error handling of gp_aux_bus_probe()

When auxiliary_device_add() returns error and then calls
auxiliary_device_uninit(), callback function
gp_auxiliary_device_release() calls ida_free() and
kfree(aux_device_wrapper) to free memory. We should't
call them again in the error handling path.

Fix this by skipping the redundant cleanup functions.

Fixes: 393fc2f5948f ("misc: microchip: pci1xxxx: load auxiliary bus driver for the PIO function in the multi-function endpoint of pci1xxxx device.")
Signed-off-by: Yongzhi Liu <hyperlyzcs@gmail.com>
Link: https://lore.kernel.org/r/20240523121434.21855-3-hyperlyzcs@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c