Commit b28fd7b5 authored by From: Tuomas Tynkkynen's avatar From: Tuomas Tynkkynen Committed by Dave Chinner

xfs: Fix wrong error codes being returned

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: default avatarTuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 3c353375
...@@ -543,10 +543,11 @@ xfs_attrmulti_by_handle( ...@@ -543,10 +543,11 @@ xfs_attrmulti_by_handle(
ops = memdup_user(am_hreq.ops, size); ops = memdup_user(am_hreq.ops, size);
if (IS_ERR(ops)) { if (IS_ERR(ops)) {
error = PTR_ERR(ops); error = -PTR_ERR(ops);
goto out_dput; goto out_dput;
} }
error = ENOMEM;
attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL); attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL);
if (!attr_name) if (!attr_name)
goto out_kfree_ops; goto out_kfree_ops;
...@@ -556,7 +557,7 @@ xfs_attrmulti_by_handle( ...@@ -556,7 +557,7 @@ xfs_attrmulti_by_handle(
ops[i].am_error = strncpy_from_user((char *)attr_name, ops[i].am_error = strncpy_from_user((char *)attr_name,
ops[i].am_attrname, MAXNAMELEN); ops[i].am_attrname, MAXNAMELEN);
if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN) if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN)
error = -ERANGE; error = ERANGE;
if (ops[i].am_error < 0) if (ops[i].am_error < 0)
break; break;
......
...@@ -424,10 +424,11 @@ xfs_compat_attrmulti_by_handle( ...@@ -424,10 +424,11 @@ xfs_compat_attrmulti_by_handle(
ops = memdup_user(compat_ptr(am_hreq.ops), size); ops = memdup_user(compat_ptr(am_hreq.ops), size);
if (IS_ERR(ops)) { if (IS_ERR(ops)) {
error = PTR_ERR(ops); error = -PTR_ERR(ops);
goto out_dput; goto out_dput;
} }
error = ENOMEM;
attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL); attr_name = kmalloc(MAXNAMELEN, GFP_KERNEL);
if (!attr_name) if (!attr_name)
goto out_kfree_ops; goto out_kfree_ops;
...@@ -438,7 +439,7 @@ xfs_compat_attrmulti_by_handle( ...@@ -438,7 +439,7 @@ xfs_compat_attrmulti_by_handle(
compat_ptr(ops[i].am_attrname), compat_ptr(ops[i].am_attrname),
MAXNAMELEN); MAXNAMELEN);
if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN) if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN)
error = -ERANGE; error = ERANGE;
if (ops[i].am_error < 0) if (ops[i].am_error < 0)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment