[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YvnS7IKr/9VhffHX@google.com>
Date: Mon, 15 Aug 2022 05:00:28 +0000
From: Tzung-Bi Shih <tzungbi@...nel.org>
To: Rustam Subkhankulov <subkhankulov@...ras.ru>
Cc: Benson Leung <bleung@...omium.org>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
chrome-platform@...ts.linux.dev, linux-kernel@...r.kernel.org,
Alexey Khoroshilov <khoroshilov@...ras.ru>,
ldv-project@...uxtesting.org
Subject: Re: [PATCH] platform/chrome: fix double-free in
chromeos_laptop_prepare()
On Sun, Aug 14, 2022 at 01:08:43AM +0300, Rustam Subkhankulov wrote:
> 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.
Alternatively, I would prefer to fix the double-free by setting
`i2c_peripherals` to NULL after [1].
[1]: https://elixir.bootlin.com/linux/v5.19/source/drivers/platform/chrome/chromeos_laptop.c#L787
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
After a quick glance, I found an invalid memory access at [2] if
`i2c_peripherals` is NULL (see [3]). Do you have a real machine to perform
some module load/unload tests? Or was the double-free issue discovered by
some static analysis?
[2]: https://elixir.bootlin.com/linux/v5.19/source/drivers/platform/chrome/chromeos_laptop.c#L860
[3]: https://elixir.bootlin.com/linux/v5.19/source/drivers/platform/chrome/chromeos_laptop.c#L756
Powered by blists - more mailing lists