summaryrefslogtreecommitdiff
path: root/fs/bcachefs/darray.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-06-30 16:35:37 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2022-10-14 04:59:38 -0400
commit29f20baecf850c6381a48ceb57dcefac8e15bd5b (patch)
tree0436e075bd8499e67ae70887e3b7b1ee6f823394 /fs/bcachefs/darray.h
parentd91a7b6ebca99e6140c913038614f153bc4d4610 (diff)
bcachefs: Fixes for 4.19bcachefs-v4.19-backport-2.0
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; \