Commit ffcf9ec7 authored by Stijn Tintel's avatar Stijn Tintel Committed by Kent Overstreet

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: default avatarStijn Tintel <stijn@linux-ipv6.be>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 909004d2
......@@ -32,6 +32,7 @@
#include <linux/random.h>
#include <linux/seq_file.h>
#include <linux/statfs.h>
#include <linux/string.h>
#include <linux/xattr.h>
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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment