On Thu, Sep 14, 2023 at 05:58:48PM +0300, Dan Carpenter wrote: > The strndup_user() function returns error pointers on error. It never > returns NULL. Fix the checks including the commented out code. My preferred style in bcachefs is ret = PTR_ERR_OR_ZERO(p); if (ret) return ret; It keeps things consistent when we're doing a goto err instead of a return. > > Fixes: e0750d947352 ("bcachefs: Initial commit") > Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> > --- > fs/bcachefs/chardev.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c > index e5e9fddddfb5..5556bb2dc539 100644 > --- a/fs/bcachefs/chardev.c > +++ b/fs/bcachefs/chardev.c > @@ -86,8 +86,8 @@ 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; > + if (IS_ERR(devs[i])) { > + ret = PTR_ERR(devs[i]); > goto err; > } > } > @@ -117,8 +117,8 @@ 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; > + if (IS_ERR(path)) > + return PTR_ERR(path); > > err = bch2_fs_open_incremental(path); > kfree(path); > @@ -189,8 +189,8 @@ 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; > + if (IS_ERR(path)) > + return PTR_ERR(path); > > ret = bch2_dev_add(c, path); > kfree(path); > @@ -231,8 +231,8 @@ 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; > + if (IS_ERR(path)) > + return PTR_ERR(path); > > ret = bch2_dev_online(c, path); > kfree(path); > -- > 2.39.2 >