From: Dan Carpenter <error27@gmail.com>
To: Punnay Sharma <punnaysharma805@gmail.com>
Cc: Hans de Goede <hansg@kernel.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Andy Shevchenko <andy@kernel.org>,
linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] media: atomisp: ov2722: Return after failed pad initialization
Date: Tue, 15 Sep 2026 18:38:40 +0300 [thread overview]
Message-ID: <aqlmgA3HNfxbvjXF@stanley.mountain> (raw)
In-Reply-To: <20260915140828.25537-1-punnaysharma805@gmail.com>
On Tue, Sep 15, 2026 at 07:38:28PM +0530, Punnay Sharma wrote:
> If media_entity_pads_init() fails, ov2722_probe() calls
> ov2722_remove(), which frees the device structure. The probe then
> continues into atomisp_register_i2c_module() with a pointer to the
> freed subdevice, causing a use-after-free.
>
> Return the original error immediately after cleanup to prevent
> registration from accessing the freed device.
>
> Signed-off-by: Punnay Sharma <punnaysharma805@gmail.com>
This needs a Fixes tag.
> ---
> drivers/staging/media/atomisp/i2c/atomisp-ov2722.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c
> index 2c41c496daa6..0748247ca42c 100644
> --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c
> +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c
> @@ -979,8 +979,10 @@ static int ov2722_probe(struct i2c_client *client)
> dev->sd.entity.function = MEDIA_ENT_F_CAM_SENSOR;
>
> ret = media_entity_pads_init(&dev->sd.entity, 1, &dev->pad);
> - if (ret)
> + if (ret) {
> ov2722_remove(client);
> + return ret;
> + }
>
> return atomisp_register_i2c_module(&dev->sd, ovpdev);
The bug you are describing is real and your patch fixes it, but
this isn't a complete fix. For example, there is no cleanup if
atomisp_register_i2c_module() fails.
regards,
dan carpenter
next prev parent reply other threads:[~2026-09-15 15:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 14:08 Punnay Sharma
2026-09-15 15:38 ` Dan Carpenter [this message]
2026-09-16 7:36 ` [PATCH v2] media: atomisp: ov2722: Clean up resources on probe failure Punnay Sharma
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=aqlmgA3HNfxbvjXF@stanley.mountain \
--to=error27@gmail.com \
--cc=andy@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hansg@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=punnaysharma805@gmail.com \
--cc=sakari.ailus@linux.intel.com \
/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
all inboxes | Powered by JetHome®