]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bcachefs: Fix freeing of error pointers
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 22 Jun 2024 21:22:24 +0000 (17:22 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 22 Jun 2024 21:22:24 +0000 (17:22 -0400)
This fixes incorrect/missign checking of strndup_user() returns.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/chardev.c

index 9e54323f0f5fce6a9e10fa252a2ec16f81ec3154..6d82e1165adc2da028f88f98d704f0ff7676b0d0 100644 (file)
@@ -216,7 +216,8 @@ static long bch2_ioctl_fsck_offline(struct bch_ioctl_fsck_offline __user *user_a
 
                ret =   PTR_ERR_OR_ZERO(optstr) ?:
                        bch2_parse_mount_opts(NULL, &thr->opts, optstr);
-               kfree(optstr);
+               if (!IS_ERR(optstr))
+                       kfree(optstr);
 
                if (ret)
                        goto err;
@@ -319,7 +320,8 @@ static long bch2_ioctl_disk_add(struct bch_fs *c, struct bch_ioctl_disk arg)
                return ret;
 
        ret = bch2_dev_add(c, path);
-       kfree(path);
+       if (!IS_ERR(path))
+               kfree(path);
 
        return ret;
 }
@@ -850,7 +852,8 @@ static long bch2_ioctl_fsck_online(struct bch_fs *c,
 
                ret =   PTR_ERR_OR_ZERO(optstr) ?:
                        bch2_parse_mount_opts(c, &thr->opts, optstr);
-               kfree(optstr);
+               if (!IS_ERR(optstr))
+                       kfree(optstr);
 
                if (ret)
                        goto err;