Skip to content

Commit 9bd0150

Browse files
author
Kent Overstreet
committed
bcachefs: Fix freeing of error pointers
This fixes incorrect/missign checking of strndup_user() returns. Signed-off-by: Kent Overstreet <[email protected]>
1 parent bd4da04 commit 9bd0150

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fs/bcachefs/chardev.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ static long bch2_ioctl_fsck_offline(struct bch_ioctl_fsck_offline __user *user_a
216216

217217
ret = PTR_ERR_OR_ZERO(optstr) ?:
218218
bch2_parse_mount_opts(NULL, &thr->opts, optstr);
219-
kfree(optstr);
219+
if (!IS_ERR(optstr))
220+
kfree(optstr);
220221

221222
if (ret)
222223
goto err;
@@ -319,7 +320,8 @@ static long bch2_ioctl_disk_add(struct bch_fs *c, struct bch_ioctl_disk arg)
319320
return ret;
320321

321322
ret = bch2_dev_add(c, path);
322-
kfree(path);
323+
if (!IS_ERR(path))
324+
kfree(path);
323325

324326
return ret;
325327
}
@@ -850,7 +852,8 @@ static long bch2_ioctl_fsck_online(struct bch_fs *c,
850852

851853
ret = PTR_ERR_OR_ZERO(optstr) ?:
852854
bch2_parse_mount_opts(c, &thr->opts, optstr);
853-
kfree(optstr);
855+
if (!IS_ERR(optstr))
856+
kfree(optstr);
854857

855858
if (ret)
856859
goto err;

0 commit comments

Comments
 (0)