Re: [PATCH] usb: misc: chaoskey: remove useless else

From: Keith Packard
Date: Fri Aug 13 2021 - 13:47:17 EST


Salah Triki <salah.triki@xxxxxxxxx> 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: signature.asc
Description: PGP signature