diff mbox

Input: uinput - unlock on allocation failure in ioctl

Message ID 20171108083946.vbsixgkodhw6jh4q@mwanda (mailing list archive)
State Accepted
Headers show

Commit Message

Dan Carpenter Nov. 8, 2017, 8:39 a.m. UTC
We have to unlock before returning if input_allocate_device() fails.

Fixes: 04ce40a61a91 ("Input: uinput - remove uinput_allocate_device()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Dmitry Torokhov Nov. 10, 2017, 6:22 p.m. UTC | #1
On Wed, Nov 08, 2017 at 11:39:46AM +0300, Dan Carpenter wrote:
> We have to unlock before returning if input_allocate_device() fails.
> 
> Fixes: 04ce40a61a91 ("Input: uinput - remove uinput_allocate_device()")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, thank you.


> 
> diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
> index 7b41aad7ec27..39ddd9a73feb 100644
> --- a/drivers/input/misc/uinput.c
> +++ b/drivers/input/misc/uinput.c
> @@ -857,8 +857,10 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
>  
>  	if (!udev->dev) {
>  		udev->dev = input_allocate_device();
> -		if (!udev->dev)
> -			return -ENOMEM;
> +		if (!udev->dev) {
> +			retval = -ENOMEM;
> +			goto out;
> +		}
>  	}
>  
>  	switch (cmd) {
diff mbox

Patch

diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 7b41aad7ec27..39ddd9a73feb 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -857,8 +857,10 @@  static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
 
 	if (!udev->dev) {
 		udev->dev = input_allocate_device();
-		if (!udev->dev)
-			return -ENOMEM;
+		if (!udev->dev) {
+			retval = -ENOMEM;
+			goto out;
+		}
 	}
 
 	switch (cmd) {