summaryrefslogtreecommitdiff
path: root/fs/bcachefs/darray.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs/darray.h')
-rw-r--r--fs/bcachefs/darray.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/fs/bcachefs/darray.h b/fs/bcachefs/darray.h
index 519ab9b96e67..6de0c1c8ae36 100644
--- a/fs/bcachefs/darray.h
+++ b/fs/bcachefs/darray.h
@@ -11,6 +11,19 @@
#include "util.h"
#include <linux/slab.h>
+static inline void * __must_check krealloc_array(void *p,
+ size_t new_n,
+ size_t new_size,
+ gfp_t flags)
+{
+ size_t bytes;
+
+ if (unlikely(check_mul_overflow(new_n, new_size, &bytes)))
+ return NULL;
+
+ return krealloc(p, bytes, flags);
+}
+
#define DARRAY(type) \
struct { \
size_t nr, size; \