public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring/kbuf: Fix an NULL vs IS_ERR() bug in io_alloc_pbuf_ring()
@ 2023-12-05 12:37 Dan Carpenter
  2023-12-05 14:00 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-12-05 12:37 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Pavel Begunkov, io-uring, linux-kernel, kernel-janitors

The io_mem_alloc() function returns error pointers, not NULL.  Update
the check accordingly.

Fixes: b10b73c102a2 ("io_uring/kbuf: recycle freed mapped buffer ring entries")
Signed-off-by: Dan Carpenter <[email protected]>
---
 io_uring/kbuf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c
index 268788305b61..bd25bc2deeaf 100644
--- a/io_uring/kbuf.c
+++ b/io_uring/kbuf.c
@@ -636,8 +636,8 @@ static int io_alloc_pbuf_ring(struct io_ring_ctx *ctx,
 	ibf = io_lookup_buf_free_entry(ctx, ring_size);
 	if (!ibf) {
 		ptr = io_mem_alloc(ring_size);
-		if (!ptr)
-			return -ENOMEM;
+		if (IS_ERR(ptr))
+			return PTR_ERR(ptr);
 
 		/* Allocate and store deferred free entry */
 		ibf = kmalloc(sizeof(*ibf), GFP_KERNEL_ACCOUNT);
-- 
2.42.0


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

* Re: [PATCH] io_uring/kbuf: Fix an NULL vs IS_ERR() bug in io_alloc_pbuf_ring()
  2023-12-05 12:37 [PATCH] io_uring/kbuf: Fix an NULL vs IS_ERR() bug in io_alloc_pbuf_ring() Dan Carpenter
@ 2023-12-05 14:00 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2023-12-05 14:00 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Pavel Begunkov, io-uring, linux-kernel, kernel-janitors


On Tue, 05 Dec 2023 15:37:17 +0300, Dan Carpenter wrote:
> The io_mem_alloc() function returns error pointers, not NULL.  Update
> the check accordingly.
> 
> 

Applied, thanks!

[1/1] io_uring/kbuf: Fix an NULL vs IS_ERR() bug in io_alloc_pbuf_ring()
      commit: e53f7b54b1fdecae897f25002ff0cff04faab228

Best regards,
-- 
Jens Axboe




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

end of thread, other threads:[~2023-12-05 14:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-05 12:37 [PATCH] io_uring/kbuf: Fix an NULL vs IS_ERR() bug in io_alloc_pbuf_ring() Dan Carpenter
2023-12-05 14:00 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox