All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Packard <keithp@keithp.com>
To: Salah Triki <salah.triki@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: misc: chaoskey: remove useless else
Date: Fri, 13 Aug 2021 10:38:34 -0700	[thread overview]
Message-ID: <87bl61utwl.fsf@keithp.com> (raw)
In-Reply-To: <20210813164049.GA2310720@pc>

[-- Attachment #1: Type: text/plain, Size: 510 bytes --]

Salah Triki <salah.triki@gmail.com> writes:

> Remove useless else in order to make the code cleaner.

> -	if (!dev->present) {
> -		if (dev->open == 0) {
> -			mutex_unlock(&dev->lock);
> +	mutex_unlock(&dev->lock);
> +
> +	if (!dev->present)
> +		if (dev->open == 0)
>  			chaoskey_free(dev);
> -		} else
> -			mutex_unlock(&dev->lock);
> -	} else
> -		mutex_unlock(&dev->lock);

This accesses dev->present outside of the lock region introducing a
potential race condition.

-- 
-keith

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2021-08-13 17:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13 16:40 [PATCH] usb: misc: chaoskey: remove useless else Salah Triki
2021-08-13 17:38 ` Keith Packard [this message]
2021-08-14  6:34 ` Greg Kroah-Hartman

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=87bl61utwl.fsf@keithp.com \
    --to=keithp@keithp.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=salah.triki@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.