mirror of
https://github.com/torvalds/linux.git
synced 2026-06-05 04:56:13 +02:00
bcachefs: Fix strndup_user() error checking
strndup_user() returns an error pointer, not NULL. Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
cfda31c033
commit
97ecc23632
|
|
@ -86,10 +86,9 @@ static long bch2_ioctl_assemble(struct bch_ioctl_assemble __user *user_arg)
|
|||
devs[i] = strndup_user((const char __user *)(unsigned long)
|
||||
user_devs[i],
|
||||
PATH_MAX);
|
||||
if (!devs[i]) {
|
||||
ret = -ENOMEM;
|
||||
ret= PTR_ERR_OR_ZERO(devs[i]);
|
||||
if (ret)
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
c = bch2_fs_open(devs, arg.nr_devs, bch2_opts_empty());
|
||||
|
|
@ -117,8 +116,9 @@ static long bch2_ioctl_incremental(struct bch_ioctl_incremental __user *user_arg
|
|||
return -EINVAL;
|
||||
|
||||
path = strndup_user((const char __user *)(unsigned long) arg.dev, PATH_MAX);
|
||||
if (!path)
|
||||
return -ENOMEM;
|
||||
ret = PTR_ERR_OR_ZERO(path);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
err = bch2_fs_open_incremental(path);
|
||||
kfree(path);
|
||||
|
|
@ -189,8 +189,9 @@ static long bch2_ioctl_disk_add(struct bch_fs *c, struct bch_ioctl_disk arg)
|
|||
return -EINVAL;
|
||||
|
||||
path = strndup_user((const char __user *)(unsigned long) arg.dev, PATH_MAX);
|
||||
if (!path)
|
||||
return -ENOMEM;
|
||||
ret = PTR_ERR_OR_ZERO(path);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = bch2_dev_add(c, path);
|
||||
kfree(path);
|
||||
|
|
@ -231,8 +232,9 @@ static long bch2_ioctl_disk_online(struct bch_fs *c, struct bch_ioctl_disk arg)
|
|||
return -EINVAL;
|
||||
|
||||
path = strndup_user((const char __user *)(unsigned long) arg.dev, PATH_MAX);
|
||||
if (!path)
|
||||
return -ENOMEM;
|
||||
ret = PTR_ERR_OR_ZERO(path);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = bch2_dev_online(c, path);
|
||||
kfree(path);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user