linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] misc: ocxl: fix possible refcount leak in afu_ioctl()
@ 2022-08-24  8:26 Hangyu Hua
  2022-08-24  9:42 ` Frederic Barrat
  0 siblings, 1 reply; 2+ messages in thread
From: Hangyu Hua @ 2022-08-24  8:26 UTC (permalink / raw)
  To: fbarrat, ajd, arnd, gregkh, alastair, mpe
  Cc: linuxppc-dev, linux-kernel, Hangyu Hua

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(+)

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:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] misc: ocxl: fix possible refcount leak in afu_ioctl()
  2022-08-24  8:26 [PATCH] misc: ocxl: fix possible refcount leak in afu_ioctl() Hangyu Hua
@ 2022-08-24  9:42 ` Frederic Barrat
  0 siblings, 0 replies; 2+ messages in thread
From: Frederic Barrat @ 2022-08-24  9:42 UTC (permalink / raw)
  To: Hangyu Hua, ajd, arnd, gregkh, alastair, mpe; +Cc: linuxppc-dev, linux-kernel



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:

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-24  9:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-24  8:26 [PATCH] misc: ocxl: fix possible refcount leak in afu_ioctl() Hangyu Hua
2022-08-24  9:42 ` Frederic Barrat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).