Linux Media Controller development
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Shih-Sheng Yang <yshihsheng@gmail.com>
Cc: hverkuil+cisco@kernel.org, kees@kernel.org,
	linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
	mchehab@kernel.org, Sakari Ailus <sakari.ailus@iki.fi>
Subject: Re: [PATCH] media: v4l2-dev: fix media controller registration error handling
Date: Tue, 30 Jun 2026 13:24:29 +0300	[thread overview]
Message-ID: <20260630102429.GA3199975@killaraus.ideasonboard.com> (raw)
In-Reply-To: <20260630095456.1745545-1-yshihsheng@gmail.com>

On Tue, Jun 30, 2026 at 05:54:56PM +0800, Shih-Sheng Yang wrote:
> Hi Laurent,
> 
> Thank you for the review.
> 
> I've addressed this in v2 by moving the NULL check into
> media_devnode_remove() and by using device_unregister() in
> __video_register_device(), as device_register() has already succeeded
> there.
> 
> I also checked the other media_devnode_remove() callers. I didn't find
> another caller with the same failure pattern or an immediate risk that
> requires changing the helper API. Since changing media_devnode_remove()
> to take a pointer-to-pointer would affect a wider set of callers, I have
> left that out of v2. I can add it if you prefer.

Sakari, Hans, to you have an opinion on that pattern ? If you forget the
context, the idea is to turn

void media_devnode_remove(struct media_intf_devnode *devnode)
{
	media_remove_intf_links(&devnode->intf);
	media_gobj_destroy(&devnode->intf.graph_obj);
	kfree(devnode);
}

into

void media_devnode_remove(struct media_intf_devnode **devnode)
{
	struct media_intf_devnode *node = *devnode;

	if (!node)
		return; 

	media_remove_intf_links(&node->intf);
	media_gobj_destroy(&node->intf.graph_obj);
	kfree(node);

	*devnode = NULL;
}

(bikeshedding on whether or not we need a local variable is left for
later)

I think the pattern is safer, but it's not common in V4L2 at the moment.

-- 
Regards,

Laurent Pinchart

      reply	other threads:[~2026-06-30 10:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-25 19:39 [PATCH] media: v4l2-dev: fix media controller registration error handling Shih-Sheng Yang
2026-06-26 19:22 ` Laurent Pinchart
2026-06-30  9:54   ` Shih-Sheng Yang
2026-06-30 10:24     ` Laurent Pinchart [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=20260630102429.GA3199975@killaraus.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@iki.fi \
    --cc=yshihsheng@gmail.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