On Sat, Jul 25, 2020 at 06:34:16AM +0000, Wei Yongjun wrote:
> Add the missing unlock before return from function mtdchar_compat_ioctl()
> in the error handling case.
> 
> Fixes: 210bec567936 ("mtd: properly check all write ioctls for permissions")
> Reported-by: Hulk Robot <[email protected]>
> Signed-off-by: Wei Yongjun <[email protected]>
> ---
>  drivers/mtd/mtdchar.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
> index 52c120f9fb0d..b40f46a43fc6 100644
> --- a/drivers/mtd/mtdchar.c
> +++ b/drivers/mtd/mtdchar.c
> @@ -1064,8 +1064,10 @@ static long mtdchar_compat_ioctl(struct file *file, 
> unsigned int cmd,
>               struct mtd_oob_buf32 buf;
>               struct mtd_oob_buf32 __user *buf_user = argp;
>  
> -             if (!(file->f_mode & FMODE_WRITE))
> -                     return -EPERM;
> +             if (!(file->f_mode & FMODE_WRITE)) {
> +                     ret = -EPERM;
> +                     break;
> +             }
>  
>               if (copy_from_user(&buf, argp, sizeof(buf)))
>                       ret = -EFAULT;
> 
> 
> 

I think Richard already resolved this in his tree, but I could be wrong.

And nice detection by your bot, that's good to see.

thanks,

greg k-h

Reply via email to