2019-05-04 06:56:27

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH -next] ocxl: Fix return value check in afu_ioctl()

In case of error, the function eventfd_ctx_fdget() returns ERR_PTR() and
never returns NULL. The NULL test in the return value check should be
replaced with IS_ERR().

This issue was detected by using the Coccinelle software.

Fixes: 060146614643 ("ocxl: move event_fd handling to frontend")
Signed-off-by: Wei Yongjun <[email protected]>
---
drivers/misc/ocxl/file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
index 8aa22893ed76..2870c25da166 100644
--- a/drivers/misc/ocxl/file.c
+++ b/drivers/misc/ocxl/file.c
@@ -257,8 +257,8 @@ static long afu_ioctl(struct file *file, unsigned int cmd,
return -EINVAL;
irq_id = ocxl_irq_offset_to_id(ctx, irq_fd.irq_offset);
ev_ctx = eventfd_ctx_fdget(irq_fd.eventfd);
- if (!ev_ctx)
- return -EFAULT;
+ if (IS_ERR(ev_ctx))
+ return PTR_ERR(ev_ctx);
rc = ocxl_irq_set_handler(ctx, irq_id, irq_handler, irq_free, ev_ctx);
break;




2019-05-05 05:55:49

by Alastair D'Silva

[permalink] [raw]
Subject: RE: [PATCH -next] ocxl: Fix return value check in afu_ioctl()

> -----Original Message-----
> From: Wei Yongjun <[email protected]>
> Sent: Saturday, 4 May 2019 5:05 PM
> To: Frederic Barrat <[email protected]>; Andrew Donnellan
> <[email protected]>; Arnd Bergmann <[email protected]>; Greg Kroah-
> Hartman <[email protected]>; Alastair D'Silva <alastair@d-
> silva.org>
> Cc: Wei Yongjun <[email protected]>; linuxppc-
> [email protected]; [email protected]; kernel-
> [email protected]
> Subject: [PATCH -next] ocxl: Fix return value check in afu_ioctl()
>
> In case of error, the function eventfd_ctx_fdget() returns ERR_PTR() and
> never returns NULL. The NULL test in the return value check should be
> replaced with IS_ERR().
>
> This issue was detected by using the Coccinelle software.
>
> Fixes: 060146614643 ("ocxl: move event_fd handling to frontend")
> Signed-off-by: Wei Yongjun <[email protected]>
> ---
> drivers/misc/ocxl/file.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index
> 8aa22893ed76..2870c25da166 100644
> --- a/drivers/misc/ocxl/file.c
> +++ b/drivers/misc/ocxl/file.c
> @@ -257,8 +257,8 @@ static long afu_ioctl(struct file *file, unsigned int
cmd,
> return -EINVAL;
> irq_id = ocxl_irq_offset_to_id(ctx, irq_fd.irq_offset);
> ev_ctx = eventfd_ctx_fdget(irq_fd.eventfd);
> - if (!ev_ctx)
> - return -EFAULT;
> + if (IS_ERR(ev_ctx))
> + return PTR_ERR(ev_ctx);
> rc = ocxl_irq_set_handler(ctx, irq_id, irq_handler,
irq_free,
> ev_ctx);
> break;

LGTM

Acked-by: Alastair D'Silva <[email protected]>

--
Alastair D'Silva mob: 0423 762 819
skype: alastair_dsilva msn: [email protected]
blog: http://alastair.d-silva.org Twitter: @EvilDeece

2019-05-05 15:11:46

by Andrew Donnellan

[permalink] [raw]
Subject: Re: [PATCH -next] ocxl: Fix return value check in afu_ioctl()

On 4/5/19 5:04 pm, Wei Yongjun wrote:
> In case of error, the function eventfd_ctx_fdget() returns ERR_PTR() and
> never returns NULL. The NULL test in the return value check should be
> replaced with IS_ERR().
>
> This issue was detected by using the Coccinelle software.
>
> Fixes: 060146614643 ("ocxl: move event_fd handling to frontend")
> Signed-off-by: Wei Yongjun <[email protected]>

Acked-by: Andrew Donnellan <[email protected]>

> ---
> drivers/misc/ocxl/file.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
> index 8aa22893ed76..2870c25da166 100644
> --- a/drivers/misc/ocxl/file.c
> +++ b/drivers/misc/ocxl/file.c
> @@ -257,8 +257,8 @@ static long afu_ioctl(struct file *file, unsigned int cmd,
> return -EINVAL;
> irq_id = ocxl_irq_offset_to_id(ctx, irq_fd.irq_offset);
> ev_ctx = eventfd_ctx_fdget(irq_fd.eventfd);
> - if (!ev_ctx)
> - return -EFAULT;
> + if (IS_ERR(ev_ctx))
> + return PTR_ERR(ev_ctx);
> rc = ocxl_irq_set_handler(ctx, irq_id, irq_handler, irq_free, ev_ctx);
> break;
>
>
>

--
Andrew Donnellan OzLabs, ADL Canberra
[email protected] IBM Australia Limited

2019-05-06 13:57:20

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH -next] ocxl: Fix return value check in afu_ioctl()

On Sat, 2019-05-04 at 07:04:30 UTC, Wei Yongjun wrote:
> In case of error, the function eventfd_ctx_fdget() returns ERR_PTR() and
> never returns NULL. The NULL test in the return value check should be
> replaced with IS_ERR().
>
> This issue was detected by using the Coccinelle software.
>
> Fixes: 060146614643 ("ocxl: move event_fd handling to frontend")
> Signed-off-by: Wei Yongjun <[email protected]>
> Acked-by: Alastair D'Silva <[email protected]>
> Acked-by: Andrew Donnellan <[email protected]>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/6be6a8de1b55e719e3f9589491074371

cheers