]> git.karo-electronics.de Git - linux-beck.git/commitdiff
xfs: Fix wrong error codes being returned
authorFrom: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Mon, 5 May 2014 07:30:20 +0000 (17:30 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 5 May 2014 07:30:20 +0000 (17:30 +1000)
xfs_{compat_,}attrmulti_by_handle could return an errno with incorrect
sign in some cases. While at it, make sure ENOMEM is returned instead of
E2BIG if kmalloc fails.

Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_ioctl.c
fs/xfs/xfs_ioctl32.c

index 0b18776b075e44fb7f7d818183fa03dcfc7b3f4d..2d8f4fdf07f9b3b595a443e1258c18b98972aa75 100644 (file)
@@ -543,10 +543,11 @@ xfs_attrmulti_by_handle(
 
        ops = memdup_user(am_hreq.ops, size);
        if (IS_ERR(ops)) {
-               error = PTR_ERR(ops);
+               error = -PTR_ERR(ops);
                goto out_dput;
        }
 
+       error = ENOMEM;
        attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL);
        if (!attr_name)
                goto out_kfree_ops;
@@ -556,7 +557,7 @@ xfs_attrmulti_by_handle(
                ops[i].am_error = strncpy_from_user((char *)attr_name,
                                ops[i].am_attrname, MAXNAMELEN);
                if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN)
-                       error = -ERANGE;
+                       error = ERANGE;
                if (ops[i].am_error < 0)
                        break;
 
index a7992f8de9d3fa53a63ab2d3250f0c4933caded9..944d5baa710a39da9aa1d6a82a27013c15813d64 100644 (file)
@@ -424,10 +424,11 @@ xfs_compat_attrmulti_by_handle(
 
        ops = memdup_user(compat_ptr(am_hreq.ops), size);
        if (IS_ERR(ops)) {
-               error = PTR_ERR(ops);
+               error = -PTR_ERR(ops);
                goto out_dput;
        }
 
+       error = ENOMEM;
        attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL);
        if (!attr_name)
                goto out_kfree_ops;
@@ -438,7 +439,7 @@ xfs_compat_attrmulti_by_handle(
                                compat_ptr(ops[i].am_attrname),
                                MAXNAMELEN);
                if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN)
-                       error = -ERANGE;
+                       error = ERANGE;
                if (ops[i].am_error < 0)
                        break;