summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/bcachefs/darray.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/bcachefs/darray.c b/fs/bcachefs/darray.c
index ac35b8b705ae..b7d223f85873 100644
--- a/fs/bcachefs/darray.c
+++ b/fs/bcachefs/darray.c
@@ -13,7 +13,8 @@ int __bch2_darray_resize(darray_char *d, size_t element_size, size_t new_size, g
if (!data)
return -ENOMEM;
- memcpy(data, d->data, d->size * element_size);
+ if (d->size)
+ memcpy(data, d->data, d->size * element_size);
if (d->data != d->preallocated)
kvfree(d->data);
d->data = data;