Skip to content

Commit 6e6e41c

Browse files
jasowangdavem330
authored andcommitted
ptr_ring: fail early if queue occupies more than KMALLOC_MAX_SIZE
To avoid slab to warn about exceeded size, fail early if queue occupies more than KMALLOC_MAX_SIZE. Reported-by: [email protected] Fixes: 2e0ab8c ("ptr_ring: array based FIFO for pointers") Signed-off-by: Jason Wang <[email protected]> Acked-by: Michael S. Tsirkin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 909ebd5 commit 6e6e41c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/linux/ptr_ring.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ static inline int ptr_ring_consume_batched_bh(struct ptr_ring *r,
466466

467467
static inline void **__ptr_ring_init_queue_alloc(unsigned int size, gfp_t gfp)
468468
{
469+
if (size * sizeof(void *) > KMALLOC_MAX_SIZE)
470+
return NULL;
469471
return kcalloc(size, sizeof(void *), gfp);
470472
}
471473

0 commit comments

Comments
 (0)