[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-kernel
Subject:    Re: [PATCH] usb: misc: chaoskey: remove useless else
From:       Keith Packard <keithp () keithp ! com>
Date:       2021-08-13 17:38:34
Message-ID: 87bl61utwl.fsf () keithp ! com
[Download RAW message or body]


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

["signature.asc" (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic