linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sylwester Nawrocki <snjw23@gmail.com>
To: linux-media@vger.kernel.org
Cc: Sylwester Nawrocki <s.nawrocki@samsung.com>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	sw0312.kim@samsung.com, Kyungmin Park <kyungmin.park@samsung.com>,
	Hans Verkuil <hverkuil@xs4all.nl>
Subject: Re: [PATCH] s5p-fimc: Fix platform entities registration
Date: Sat, 27 Oct 2012 22:44:20 +0200	[thread overview]
Message-ID: <508C47A4.1090607@gmail.com> (raw)
In-Reply-To: <508933D1.80308@samsung.com>

On 10/25/2012 02:42 PM, Sylwester Nawrocki wrote:
> Hi Laurent,
> 
> On 10/25/2012 01:35 PM, Laurent Pinchart wrote:
>> On Thursday 25 October 2012 11:06:56 Sylwester Nawrocki wrote:
>>> Make sure there is no v4l2_device_unregister_subdev() call
>>> on a subdev which wasn't registered.
>>
>> I'm not implying that this fix is bad, but doesn't the V4L2 core already
>> handle this ? v4l2_device_unregister_subdev() returns immediately without
>> doing anything if the subdev hasn't been registered.
> 
> Indeed, the patch summary might be a bit misleading and incomplete.
> I of course wanted to make sure the platform subdevs are not treated
> as registered when any part of v4l2_device_register_subdev() fails.
> 
> 
> Looking at function v4l2_device_register_subdev(), I'm wondering whether
> line
>   159         sd->v4l2_dev = v4l2_dev;
> 
> shouldn't be moved right before
> 
>   190         spin_lock(&v4l2_dev->lock);
> 
> so sd->v4l2_dev is set only if we return 0 in this function ?

Hmm, no, that would be wrong. Since sd->v4l2_dev needs to be initialized
for sd->internal_ops->registered() and sd->internal_ops->registered() ops.

Still, it is possible that a subdev has the v4l2_dev field initialized and 
is not added to the v4l2_device list of subdevs (v4l2_dev->subdevs). Then 
function v4l2_device_unregister_subdev() checks for valid sd->v4l2_dev and
attempts to remove (not yet added) subdev from v4l2_dev->subdevs.

This subdev (un)registration code seems buggy, unless I'm missing something...

> Since in function v4l2_device_unregister_subdev() there is a check like
> 
>   259         /* return if it isn't registered */
>   260         if (sd == NULL || sd->v4l2_dev == NULL)
>   261                 return;
> 
> i.e. if subdev is not really registered, e.g. internal .registered
> op fails, it should be NULL.
> 
> In my case sd wasn't null since this structure was embedded in
> other one.

--
Regards,
Sylwester


  reply	other threads:[~2012-10-27 20:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-25  9:06 [PATCH] s5p-fimc: Fix platform entities registration Sylwester Nawrocki
2012-10-25 11:35 ` Laurent Pinchart
2012-10-25 12:42   ` Sylwester Nawrocki
2012-10-27 20:44     ` Sylwester Nawrocki [this message]
2012-10-25 14:07 ` Sylwester Nawrocki

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=508C47A4.1090607@gmail.com \
    --to=snjw23@gmail.com \
    --cc=hverkuil@xs4all.nl \
    --cc=kyungmin.park@samsung.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=s.nawrocki@samsung.com \
    --cc=sw0312.kim@samsung.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;
as well as URLs for NNTP newsgroup(s).