]> git.hungrycats.org Git - linux/commit
usb: misc: ljca: Fix double free in error handling path
authorYongzhi Liu <hyperlyzcs@gmail.com>
Mon, 11 Mar 2024 12:57:48 +0000 (20:57 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Apr 2024 13:11:53 +0000 (15:11 +0200)
commit420babea4f1881a7c4ea22a8e218b8c6895d3f21
tree38a18258769dacc46f6a8929b42b8e19d7c6c040
parent9723602387217caa71d623ffcce314dc39e84a09
usb: misc: ljca: Fix double free in error handling path

commit 7c9631969287a5366bc8e39cd5abff154b35fb80 upstream.

When auxiliary_device_add() returns error and then calls
auxiliary_device_uninit(), callback function ljca_auxdev_release
calls kfree(auxdev->dev.platform_data) to free the parameter data
of the function ljca_new_client_device. The callers of
ljca_new_client_device shouldn't call kfree() again
in the error handling path to free the platform data.

Fix this by cleaning up the redundant kfree() in all callers and
adding kfree() the passed in platform_data on errors which happen
before auxiliary_device_init() succeeds .

Fixes: acd6199f195d ("usb: Add support for Intel LJCA device")
Cc: stable <stable@kernel.org>
Signed-off-by: Yongzhi Liu <hyperlyzcs@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Link: https://lore.kernel.org/r/20240311125748.28198-1-hyperlyzcs@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/misc/usb-ljca.c