From: Stijn Tintel Date: Thu, 13 May 2021 20:08:47 +0000 (+0300) Subject: bcachefs: avoid out-of-bounds in split_devs X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=ffcf9ec78c133fb85ff13d8119ff404e11820834;p=linux.git 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 Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index b00f352011321..5eef67358cfb0 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -32,6 +32,7 @@ #include #include #include +#include #include static struct kmem_cache *bch2_inode_cache; @@ -1324,6 +1325,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;