platform/chrome: fix double-free in chromeos_laptop_prepare()
authorRustam Subkhankulov <subkhankulov@ispras.ru>
Sat, 13 Aug 2022 22:08:43 +0000 (01:08 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 10:34:52 +0000 (12:34 +0200)
commit27bb672c0437faf172a85928a3c5fbbc56667635
tree951c2ab4d3082d185784fa6615ab87ac20a992db
parent57dfb855bc9e3c47710ff0c5d46841c6aeb6d434
platform/chrome: fix double-free in chromeos_laptop_prepare()

[ Upstream commit 6ad4194d6a1e1d11b285989cd648ef695b4a93c0 ]

If chromeos_laptop_prepare_i2c_peripherals() fails after allocating memory
for 'cros_laptop->i2c_peripherals', this memory is freed at 'err_out' label
and nonzero value is returned. Then chromeos_laptop_destroy() is called,
resulting in double-free error.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Rustam Subkhankulov <subkhankulov@ispras.ru>
Fixes: 5020cd29d8bf ("platform/chrome: chromeos_laptop - supply properties for ACPI devices")
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20220813220843.2373004-1-subkhankulov@ispras.ru
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/platform/chrome/chromeos_laptop.c