summaryrefslogtreecommitdiff
path: root/include/linux/slab.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-08-01 20:18:33 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-08-01 22:13:03 -0400
commit87179c7a6e2a210ea57951d444a3055e883d08fa (patch)
tree3445e8b5d6724518cbc6f659f9d0b0ff59b08bfa /include/linux/slab.h
parent2d7982de784b24e24baa20eee0a97dea451b8fa7 (diff)
Update bcachefs sources to 33a60d9b05 bcachefs: Assorted fixes for clang
Diffstat (limited to 'include/linux/slab.h')
-rw-r--r--include/linux/slab.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h
index 78f906a8..25ccf1a7 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -80,9 +80,15 @@ static inline void *krealloc_array(void *p, size_t new_n, size_t new_size, gfp_t
}
#define kzalloc(size, flags) kmalloc(size, flags|__GFP_ZERO)
-#define kmalloc_array(n, size, flags) \
- ((size) != 0 && (n) > SIZE_MAX / (size) \
- ? NULL : kmalloc((n) * (size), flags))
+
+static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
+{
+ size_t bytes;
+
+ if (unlikely(check_mul_overflow(n, size, &bytes)))
+ return NULL;
+ return kmalloc(bytes, flags);
+}
#define kvmalloc_array(n, size, flags) \
((size) != 0 && (n) > SIZE_MAX / (size) \