From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Biren Pandya <birenpandya@gmail.com>
Cc: linux-media@vger.kernel.org, laurent.pinchart@ideasonboard.com,
mchehab@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: i2c: mt9p031: fix endpoint parsing use-after-free
Date: Wed, 8 Jul 2026 11:18:12 +0300 [thread overview]
Message-ID: <ak4HxM2nG7ppCLon@kekkonen.localdomain> (raw)
In-Reply-To: <20260613084849.57897-1-birenpandya@gmail.com>
Hi Biren,
On Sat, Jun 13, 2026 at 02:18:49PM +0530, Biren Pandya wrote:
> The mt9p031_probe() function calls fwnode_handle_put(np) immediately
> after parsing the endpoint. However, it subsequently calls
> fwnode_property_read_u32() twice using the same 'np' handle, leading
> to a potential use-after-free.
>
> Fix this by moving fwnode_handle_put(np) to the end of the endpoint
> property reading block, and adding it to the error path of
> v4l2_fwnode_endpoint_parse().
>
> Signed-off-by: Biren Pandya <birenpandya@gmail.com>
> ---
> drivers/media/i2c/mt9p031.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
> index ea5d43d..04c17cb 100644
> --- a/drivers/media/i2c/mt9p031.c
> +++ b/drivers/media/i2c/mt9p031.c
> @@ -1075,15 +1075,18 @@ static int mt9p031_parse_properties(struct mt9p031 *mt9p031, struct device *dev)
> return dev_err_probe(dev, -EINVAL, "endpoint node not found\n");
>
> ret = v4l2_fwnode_endpoint_parse(np, &endpoint);
> - fwnode_handle_put(np);
> - if (ret)
> + if (ret) {
> + fwnode_handle_put(np);
> return dev_err_probe(dev, -EINVAL, "could not parse endpoint\n");
> + }
>
> fwnode_property_read_u32(np, "input-clock-frequency",
> &mt9p031->ext_freq);
> fwnode_property_read_u32(np, "pixel-clock-frequency",
> &mt9p031->target_freq);
Same comment on this one -- just move these before
v4l2_fwnode_endpoint_parse().
>
> + fwnode_handle_put(np);
> +
> mt9p031->pixclk_pol = !!(endpoint.bus.parallel.flags &
> V4L2_MBUS_PCLK_SAMPLE_RISING);
>
--
Regards,
Sakari Ailus
next prev parent reply other threads:[~2026-07-08 8:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-13 8:48 [PATCH] media: i2c: mt9p031: fix endpoint parsing use-after-free Biren Pandya
2026-06-15 7:41 ` Laurent Pinchart
2026-07-08 8:18 ` Sakari Ailus [this message]
2026-07-08 12:37 ` [PATCH v2] " Biren Pandya
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=ak4HxM2nG7ppCLon@kekkonen.localdomain \
--to=sakari.ailus@linux.intel.com \
--cc=birenpandya@gmail.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.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