From: Frank Li <Frank.li@nxp.com>
To: Mirela Rabulea <mirela.rabulea@nxp.com>
Cc: sakari.ailus@linux.intel.com, mchehab@kernel.org,
laurentiu.palcu@nxp.com, robert.chiras@nxp.com,
guoniu.zhou@nxp.com, robby.cai@nxp.com,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
imx@lists.linux.dev
Subject: Re: [PATCH] media: v4l2-fwnode: Fix subdev owner overwritten in v4l2_async_register_subdev_sensor()
Date: Thu, 21 May 2026 14:45:38 -0400 [thread overview]
Message-ID: <ag9S0pUw66MDUxRA@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20260521122646.600179-1-mirela.rabulea@nxp.com>
On Thu, May 21, 2026 at 03:26:45PM +0300, Mirela Rabulea wrote:
> The v4l2 helper v4l2_async_register_subdev_sensor() calls
> v4l2_async_register_subdev(), which is a macro that expands to
> __v4l2_async_register_subdev(sd,THIS_MODULE). Since the macro is expanded
> inside v4l2-fwnode.c, THIS_MODULE resolves to the v4l2-fwnode module
> rather than the sensor driver module that originally set sd->owner. When
> v4l2-fwnode is built-in, THIS_MODULE evaluates to NULL, which then
> overwrites the sensor driver's owner with NULL.
This is problem. but this patch can't resolve problem 100% because
many sensor driver have not init sd->owner before call
v4l2_async_register_subdev_sensor()
suggest solution like what v4l2_async_register_subdev() did
rename v4l2_async_register_subdev_sensor() to
__v4l2_async_register_subdev_sensor(truct v4l2_subdev *sd, module *this)
#define v4l2_async_register_subdev_sensor(sd)
__v4l2_async_register_subdev_sensor(sd, THIS_MODULE)
Frank
>
> This causes the problem that the sensor module's reference count is never
> incremented during async registration, so the module can be removed while
> the subdevice is still in use by a notifier (e.g., a CSI-2 receiver
> bridge driver).
>
> Fix this by calling __v4l2_async_register_subdev() directly with
> sd->owner, which preserves the module owner that the sensor driver set
> during probe via v4l2_i2c_subdev_init() or direct assignment.
>
> Fixes: aef69d54755d ("media: v4l: fwnode: Add a convenience function for registering sensors")
>
> Signed-off-by: Mirela Rabulea <mirela.rabulea@nxp.com>
> ---
> drivers/media/v4l2-core/v4l2-fwnode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/v4l2-core/v4l2-fwnode.c b/drivers/media/v4l2-core/v4l2-fwnode.c
> index 77f3298821b5..57284b7adddf 100644
> --- a/drivers/media/v4l2-core/v4l2-fwnode.c
> +++ b/drivers/media/v4l2-core/v4l2-fwnode.c
> @@ -1282,7 +1282,7 @@ int v4l2_async_register_subdev_sensor(struct v4l2_subdev *sd)
> if (ret < 0)
> goto out_cleanup;
>
> - ret = v4l2_async_register_subdev(sd);
> + ret = __v4l2_async_register_subdev(sd, sd->owner);
> if (ret < 0)
> goto out_unregister;
>
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-05-21 18:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 12:26 Mirela Rabulea
2026-05-21 18:45 ` Frank Li [this message]
2026-05-22 14:30 ` Mirela Rabulea
2026-05-22 18:01 ` Frank Li
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=ag9S0pUw66MDUxRA@lizhi-Precision-Tower-5810 \
--to=frank.li@nxp.com \
--cc=guoniu.zhou@nxp.com \
--cc=imx@lists.linux.dev \
--cc=laurentiu.palcu@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mirela.rabulea@nxp.com \
--cc=robby.cai@nxp.com \
--cc=robert.chiras@nxp.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®