From 969a1a2d5c581d958ce5da37e827ed2217aac17a Mon Sep 17 00:00:00 2001 From: Stijn Tintel Date: Thu, 13 May 2021 23:08:47 +0300 Subject: bcachefs: avoid out-of-bounds in split_devs Calling mount with an empty source string causes an out-of-bounds error in split_devs. Check the length of the source string to avoid this. Signed-off-by: Stijn Tintel --- fs/bcachefs/fs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 3161760050c9..6f1512176c4d 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -30,6 +30,7 @@ #include #include #include +#include #include static struct kmem_cache *bch2_inode_cache; @@ -1310,6 +1311,9 @@ static char **split_devs(const char *_dev_name, unsigned *nr) char *dev_name = NULL, **devs = NULL, *s; size_t i, nr_devs = 0; + if (strlen(_dev_name) == 0) + return NULL; + dev_name = kstrdup(_dev_name, GFP_KERNEL); if (!dev_name) return NULL; -- cgit v1.2.3