archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <>
To: Alexander Popov <>
Cc: Hans Verkuil <>,
	Mauro Carvalho Chehab <>,
	Security Officers <>,
	Linux Media Mailing List <>,
	Linux Kernel Mailing List <>
Subject: Re: [PATCH v3 1/1] media: vivid: Fix wrong locking that causes race conditions on streaming stop
Date: Sun, 3 Nov 2019 08:45:25 -0800	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Sat, Nov 2, 2019 at 12:03 PM Alexander Popov <> wrote:
> -               mutex_lock(&dev->mutex);
> +               if (!mutex_trylock(&dev->mutex)) {
> +                       schedule_timeout(1);
> +                       continue;
> +               }
> +

I just realized that this too is wrong. It _works_, but because it
doesn't actually set the task state to anything particular before
scheduling, it's basically pointless. It calls the scheduler, but it
won't delay anything, because the task stays runnable.

So what you presumably want to use is either "cond_resched()" (to make
sure others get to run with no delay) or
"schedule_timeout_uninterruptible(1)" which actually sets the process

The above works, but it's basically nonsensical. My bad for not
noticing earlier.


  parent reply	other threads:[~2019-11-03 16:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-02 19:03 [PATCH v3 1/1] media: vivid: Fix wrong locking that causes race conditions on streaming stop Alexander Popov
2019-11-02 20:50 ` Alexander Popov
2019-11-03 16:45 ` Linus Torvalds [this message]
2019-11-03 21:44   ` Alexander Popov
2019-11-03 22:17     ` [PATCH v4 " Alexander Popov

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='' \ \ \ \ \ \ \ \

* 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).