[PATCH] ocxl: Fix potential bad errno on irq allocation

Andrew Donnellan andrew.donnellan at au1.ibm.com
Wed Feb 21 10:21:24 AEDT 2018


On 17/02/18 00:01, Frederic Barrat wrote:
> Fix some issues found by a static checker:
> 
> When allocating an AFU interrupt, if the driver cannot copy the output
> parameters to userland, the errno value was not set to EFAULT
> 
> Remove a (now) useless cast.
> 
> Reported-by: Dan Carpenter <dan.carpenter at oracle.com>
> Signed-off-by: Frederic Barrat <fbarrat at linux.vnet.ibm.com>

Acked-by: Andrew Donnellan <andrew.donnellan at au1.ibm.com>

> ---
>   drivers/misc/ocxl/file.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
> index 2dd2db9bc1c9..337462e1569f 100644
> --- a/drivers/misc/ocxl/file.c
> +++ b/drivers/misc/ocxl/file.c
> @@ -133,8 +133,10 @@ static long afu_ioctl(struct file *file, unsigned int cmd,
>   		if (!rc) {
>   			rc = copy_to_user((u64 __user *) args, &irq_offset,
>   					sizeof(irq_offset));
> -			if (rc)
> +			if (rc) {
>   				ocxl_afu_irq_free(ctx, irq_offset);
> +				return -EFAULT;
> +			}
>   		}
>   		break;
> 
> @@ -329,7 +331,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
> 
>   	used += sizeof(header);
> 
> -	rc = (ssize_t) used;
> +	rc = used;
>   	return rc;
>   }
> 

-- 
Andrew Donnellan              OzLabs, ADL Canberra
andrew.donnellan at au1.ibm.com  IBM Australia Limited



More information about the Linuxppc-dev mailing list