From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Rustam Subkhankulov <subkhankulov@ispras.ru>
Cc: Benson Leung <bleung@chromium.org>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org,
Alexey Khoroshilov <khoroshilov@ispras.ru>,
ldv-project@linuxtesting.org
Subject: Re: [PATCH] platform/chrome: fix double-free in chromeos_laptop_prepare()
Date: Mon, 15 Aug 2022 05:00:28 +0000 [thread overview]
Message-ID: <YvnS7IKr/9VhffHX@google.com> (raw)
In-Reply-To: <20220813220843.2373004-1-subkhankulov@ispras.ru>
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
next prev parent reply other threads:[~2022-08-15 5:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-13 22:08 [PATCH] platform/chrome: fix double-free in chromeos_laptop_prepare() Rustam Subkhankulov
2022-08-15 5:00 ` Tzung-Bi Shih [this message]
2022-08-20 17:05 ` Rustam Subkhankulov
2022-08-21 4:51 ` Dmitry Torokhov
2022-08-22 6:40 ` Tzung-Bi Shih
2022-08-22 7:00 ` patchwork-bot+chrome-platform
2022-08-24 2:20 ` patchwork-bot+chrome-platform
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YvnS7IKr/9VhffHX@google.com \
--to=tzungbi@kernel.org \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=dmitry.torokhov@gmail.com \
--cc=khoroshilov@ispras.ru \
--cc=ldv-project@linuxtesting.org \
--cc=linux-kernel@vger.kernel.org \
--cc=subkhankulov@ispras.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.