* [PATCH] usb: misc: chaoskey: remove useless else
@ 2021-08-13 16:40 Salah Triki
2021-08-13 17:38 ` Keith Packard
2021-08-14 6:34 ` Greg Kroah-Hartman
0 siblings, 2 replies; 3+ messages in thread
From: Salah Triki @ 2021-08-13 16:40 UTC (permalink / raw)
To: Keith Packard, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel
Remove useless else in order to make the code cleaner.
Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
drivers/usb/misc/chaoskey.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c
index 87067c3d6109..9814ac2201d5 100644
--- a/drivers/usb/misc/chaoskey.c
+++ b/drivers/usb/misc/chaoskey.c
@@ -299,14 +299,11 @@ static int chaoskey_release(struct inode *inode, struct file *file)
--dev->open;
- 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);
usb_dbg(interface, "release success");
return 0;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: misc: chaoskey: remove useless else
2021-08-13 16:40 [PATCH] usb: misc: chaoskey: remove useless else Salah Triki
@ 2021-08-13 17:38 ` Keith Packard
2021-08-14 6:34 ` Greg Kroah-Hartman
1 sibling, 0 replies; 3+ messages in thread
From: Keith Packard @ 2021-08-13 17:38 UTC (permalink / raw)
To: Salah Triki, Greg Kroah-Hartman; +Cc: linux-usb, linux-kernel
[-- 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 --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: misc: chaoskey: remove useless else
2021-08-13 16:40 [PATCH] usb: misc: chaoskey: remove useless else Salah Triki
2021-08-13 17:38 ` Keith Packard
@ 2021-08-14 6:34 ` Greg Kroah-Hartman
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2021-08-14 6:34 UTC (permalink / raw)
To: Salah Triki; +Cc: Keith Packard, linux-usb, linux-kernel
On Fri, Aug 13, 2021 at 05:40:49PM +0100, Salah Triki wrote:
> Remove useless else in order to make the code cleaner.
>
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> ---
> drivers/usb/misc/chaoskey.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/misc/chaoskey.c b/drivers/usb/misc/chaoskey.c
> index 87067c3d6109..9814ac2201d5 100644
> --- a/drivers/usb/misc/chaoskey.c
> +++ b/drivers/usb/misc/chaoskey.c
> @@ -299,14 +299,11 @@ static int chaoskey_release(struct inode *inode, struct file *file)
>
> --dev->open;
>
> - 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);
>
> usb_dbg(interface, "release success");
> return 0;
> --
> 2.25.1
>
Please fix whatever tool "found" this code to be changed so that it does
not introduce bugs again, that's a broken tool.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-08-14 6:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-13 16:40 [PATCH] usb: misc: chaoskey: remove useless else Salah Triki
2021-08-13 17:38 ` Keith Packard
2021-08-14 6:34 ` Greg Kroah-Hartman
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.