From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Biren Pandya <birenpandya@gmail.com>
Cc: sakari.ailus@linux.intel.com, mchehab@kernel.org,
dongchun.zhu@mediatek.com, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Subject: Re: [PATCH v3] media: i2c: ov02a10: fix endpoint parsing use-after-free
Date: Wed, 8 Jul 2026 17:44:32 +0300 [thread overview]
Message-ID: <ak5iUKb9MQ2noWNe@ashevche-desk.local> (raw)
In-Reply-To: <20260708130534.29329-2-birenpandya@gmail.com>
On Wed, Jul 08, 2026 at 06:35:33PM +0530, Biren Pandya wrote:
> The ov02a10_check_hwcfg() function calls fwnode_handle_put(ep)
> immediately after allocating and parsing the endpoint. However, it
> subsequently calls fwnode_property_read_u32() using the same 'ep'
> handle, leading to a potential use-after-free.
>
> Additionally, reading the optional 'ovti,mipi-clock-voltage' property
> used to overwrite the 'ret' variable. If the property was missing,
> 'ret' would become negative, and this failure code would be incorrectly
> returned at the end of the function, causing probe to fail entirely.
>
> Fix the use-after-free by moving fwnode_property_read_u32() before
> the endpoint is parsed and freed. Avoid the error leak by not
> assigning the result of fwnode_property_read_u32() to 'ret'.
...
> + /* Optional indication of MIPI clock voltage unit */
> + if (!fwnode_property_read_u32(ep, "ovti,mipi-clock-voltage",
> + &clk_volt))
Besides this being exactly a single line in length (80 chars),
the way how we check and read the optional properties is like this
if (_property_present()) {
ret = _property_read_u32();
if (ret)
return ret;
} else {
...apply default...
}
But since this is a fix, just make the above a single line for now and refactor
in a later change.
> + ov02a10->mipi_clock_voltage = clk_volt;
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-07-08 14:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-13 11:29 [PATCH v2] media: i2c: ov02a10: fix endpoint parsing use-after-free and error leak Biren Pandya
2026-06-13 12:27 ` Vladimir Zapolskiy
2026-07-08 13:05 ` [PATCH v3] media: i2c: ov02a10: fix endpoint parsing use-after-free Biren Pandya
2026-07-08 14:44 ` Andy Shevchenko [this message]
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=ak5iUKb9MQ2noWNe@ashevche-desk.local \
--to=andriy.shevchenko@linux.intel.com \
--cc=birenpandya@gmail.com \
--cc=dongchun.zhu@mediatek.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=stable@vger.kernel.org \
--cc=vladimir.zapolskiy@linaro.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox