]> www.infradead.org Git - users/hch/dma-mapping.git/commitdiff
bcachefs: skip mount option handle for empty string.
authorHongbo Li <lihongbo22@huawei.com>
Thu, 10 Oct 2024 04:01:48 +0000 (12:01 +0800)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 18 Oct 2024 04:49:48 +0000 (00:49 -0400)
The options parse in get_tree will split the options buffer, it will
get the empty string for last one by strsep(). After commit
ea0eeb89b1d5 ("bcachefs: reject unknown mount options") is merged,
unknown mount options is not allowed (here is empty string), and this
causes this errors. This can be reproduced just by the following steps:

    bcachefs format /dev/loop
    mount -t bcachefs -o metadata_target=loop1 /dev/loop1 /mnt/bcachefs/

Fixes: ea0eeb89b1d5 ("bcachefs: reject unknown mount options")
Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/opts.c

index 84097235eea9469506ef4dcfa07eba637d188210..68d240126522ad3e067ec8f4db9beae947be20f8 100644 (file)
@@ -596,6 +596,9 @@ int bch2_parse_mount_opts(struct bch_fs *c, struct bch_opts *opts,
        copied_opts_start = copied_opts;
 
        while ((opt = strsep(&copied_opts, ",")) != NULL) {
+               if (!*opt)
+                       continue;
+
                name    = strsep(&opt, "=");
                val     = opt;