mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Ian Rogers <irogers@google.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Nathan Chancellor <nathan@kernel.org>,
	linux-media@vger.kernel.org, llvm@lists.linux.dev,
	linux-kernel@vger.kernel.org, Keke Li <keke.li@amlogic.com>,
	Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Subject: Re: [PATCH 1/5] media: amlogic: c3-isp: Set .owner = THIS_MODULE in v4l2_file_operations
Date: Fri, 4 Dec 2026 10:57:23 +0900	[thread overview]
Message-ID: <20261204015723.GA613470@killaraus.ideasonboard.com> (raw)
In-Reply-To: <20261203171549.438355-2-irogers@google.com>

On Thu, Dec 03, 2026 at 09:15:43AM -0800, Ian Rogers wrote:
> video_register_device() passes vdev->fops->owner to
> __video_register_device(), which sets vdev->cdev->owner = owner so
> chrdev_open() pins the V4L2 driver module while the device node is open.
> When .owner is omitted in a const struct v4l2_file_operations,
> vdev->cdev->owner is NULL and the driver module is not reference counted
> on open().
> 
> Set .owner = THIS_MODULE in isp_cap_v4l2_fops, isp_params_v4l2_fops, and
> isp_stats_v4l2_fops, found with Clang's require_explicit_initialization
> attribute.

This sounds like a game of whack-a-mole. A better solution would be to
improve the API to make this error impossible in the first place. I'll
send an RFC.

> Fixes: fb2e135208f3 ("media: platform: Add C3 ISP driver")
> Signed-off-by: Ian Rogers <irogers@google.com>
> ---
>  drivers/media/platform/amlogic/c3/isp/c3-isp-capture.c | 1 +
>  drivers/media/platform/amlogic/c3/isp/c3-isp-params.c  | 1 +
>  drivers/media/platform/amlogic/c3/isp/c3-isp-stats.c   | 1 +
>  3 files changed, 3 insertions(+)
> 
> diff --git a/drivers/media/platform/amlogic/c3/isp/c3-isp-capture.c b/drivers/media/platform/amlogic/c3/isp/c3-isp-capture.c
> index 11d85f5342f0..da0506548d34 100644
> --- a/drivers/media/platform/amlogic/c3/isp/c3-isp-capture.c
> +++ b/drivers/media/platform/amlogic/c3/isp/c3-isp-capture.c
> @@ -502,6 +502,7 @@ static const struct v4l2_file_operations isp_cap_v4l2_fops = {
>  	.poll = vb2_fop_poll,
>  	.unlocked_ioctl = video_ioctl2,
>  	.mmap = vb2_fop_mmap,
> +	.owner = THIS_MODULE,
>  };
>  
>  static int c3_isp_cap_link_validate(struct media_link *link)
> diff --git a/drivers/media/platform/amlogic/c3/isp/c3-isp-params.c b/drivers/media/platform/amlogic/c3/isp/c3-isp-params.c
> index ae0777a20bda..686f22c99d69 100644
> --- a/drivers/media/platform/amlogic/c3/isp/c3-isp-params.c
> +++ b/drivers/media/platform/amlogic/c3/isp/c3-isp-params.c
> @@ -764,6 +764,7 @@ static const struct v4l2_file_operations isp_params_v4l2_fops = {
>  	.poll = vb2_fop_poll,
>  	.unlocked_ioctl = video_ioctl2,
>  	.mmap = vb2_fop_mmap,
> +	.owner = THIS_MODULE,
>  };
>  
>  static int c3_isp_params_vb2_queue_setup(struct vb2_queue *q,
> diff --git a/drivers/media/platform/amlogic/c3/isp/c3-isp-stats.c b/drivers/media/platform/amlogic/c3/isp/c3-isp-stats.c
> index 8a5d7e1a30c9..888a4a6434e8 100644
> --- a/drivers/media/platform/amlogic/c3/isp/c3-isp-stats.c
> +++ b/drivers/media/platform/amlogic/c3/isp/c3-isp-stats.c
> @@ -140,6 +140,7 @@ static const struct v4l2_file_operations isp_stats_v4l2_fops = {
>  	.poll = vb2_fop_poll,
>  	.unlocked_ioctl = video_ioctl2,
>  	.mmap = vb2_fop_mmap,
> +	.owner = THIS_MODULE,
>  };
>  
>  static int c3_isp_stats_vb2_queue_setup(struct vb2_queue *q,

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2026-12-04  1:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 17:15 [PATCH 0/5] media: Set missing .owner = THIS_MODULE in V4L2 and D-PHY ops Ian Rogers
2026-12-03 17:15 ` [PATCH 1/5] media: amlogic: c3-isp: Set .owner = THIS_MODULE in v4l2_file_operations Ian Rogers
2026-12-04  1:57   ` Laurent Pinchart [this message]
2026-12-03 17:15 ` [PATCH 2/5] media: rockchip: rkcif: " Ian Rogers
2026-12-03 17:15 ` [PATCH 3/5] media: rkisp1: " Ian Rogers
2026-12-03 17:15 ` [PATCH 4/5] staging: media: ipu3: " Ian Rogers
2026-12-03 17:15 ` [PATCH 5/5] media: sunxi: a83t-mipi-csi2: Set .owner = THIS_MODULE in phy_ops Ian Rogers

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=20261204015723.GA613470@killaraus.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=hverkuil@kernel.org \
    --cc=irogers@google.com \
    --cc=jacopo.mondi@ideasonboard.com \
    --cc=keke.li@amlogic.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=nathan@kernel.org \
    --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®