diff options
author | Dan Robertson <dan@dlrobertson.com> | 2021-06-10 07:52:42 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2021-06-12 15:54:00 -0400 |
commit | 78779c3db9907ab30eb6db0705d307910a7b332c (patch) | |
tree | 7dd319c4348cf51920b40c456aca9e0b396a5848 | |
parent | bbadb5ef5d532b9a726073a5e5d4fce108949eba (diff) |
bcachefs: mount: fix null deref with null devname
- Fix null deref on mount when given a null device name.
- Move the dev_name checks to return EINVAL when it is invalid.
Signed-off-by: Dan Robertson <dan@dlrobertson.com>
-rw-r--r-- | fs/bcachefs/fs.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index a95358ddefa5..07e1edcf7eae 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -1322,9 +1322,6 @@ 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; @@ -1500,6 +1497,9 @@ static struct dentry *bch2_mount(struct file_system_type *fs_type, if (ret) return ERR_PTR(ret); + if (!dev_name || strlen(dev_name) == 0) + return ERR_PTR(-EINVAL); + devs = split_devs(dev_name, &nr_devs); if (!devs) return ERR_PTR(-ENOMEM); |