diff mbox series

misc: ocxl: fix possible refcount leak in afu_ioctl()

Message ID 20220824082600.36159-1-hbh25y@gmail.com (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series misc: ocxl: fix possible refcount leak in afu_ioctl() | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 23 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 6 jobs.

Commit Message

Hangyu Hua Aug. 24, 2022, 8:26 a.m. UTC
eventfd_ctx_put need to be called to put the refcount that gotten by
eventfd_ctx_fdget when ocxl_irq_set_handler fails.

Fixes: 060146614643 ("ocxl: move event_fd handling to frontend")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---
 drivers/misc/ocxl/file.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Frederic Barrat Aug. 24, 2022, 9:42 a.m. UTC | #1
On 24/08/2022 10:26, Hangyu Hua wrote:
> eventfd_ctx_put need to be called to put the refcount that gotten by
> eventfd_ctx_fdget when ocxl_irq_set_handler fails.
> 
> Fixes: 060146614643 ("ocxl: move event_fd handling to frontend")
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
> ---


Thanks for fixing it! LGTM

Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>

   Fred


>   drivers/misc/ocxl/file.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
> index 6777c419a8da..d46dba2df5a1 100644
> --- a/drivers/misc/ocxl/file.c
> +++ b/drivers/misc/ocxl/file.c
> @@ -257,6 +257,8 @@ static long afu_ioctl(struct file *file, unsigned int cmd,
>   		if (IS_ERR(ev_ctx))
>   			return PTR_ERR(ev_ctx);
>   		rc = ocxl_irq_set_handler(ctx, irq_id, irq_handler, irq_free, ev_ctx);
> +		if (rc)
> +			eventfd_ctx_put(ev_ctx);
>   		break;
>   
>   	case OCXL_IOCTL_GET_METADATA:
diff mbox series

Patch

diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c
index 6777c419a8da..d46dba2df5a1 100644
--- a/drivers/misc/ocxl/file.c
+++ b/drivers/misc/ocxl/file.c
@@ -257,6 +257,8 @@  static long afu_ioctl(struct file *file, unsigned int cmd,
 		if (IS_ERR(ev_ctx))
 			return PTR_ERR(ev_ctx);
 		rc = ocxl_irq_set_handler(ctx, irq_id, irq_handler, irq_free, ev_ctx);
+		if (rc)
+			eventfd_ctx_put(ev_ctx);
 		break;
 
 	case OCXL_IOCTL_GET_METADATA: