[PATCH 17/33] sysctl: propagate conv errors

From: Peter Zijlstra
Date: Tue Oct 30 2007 - 12:21:28 EST


Currently conv routines will only generate -EINVAL, allow for other
errors to be propagetd.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
---
kernel/sysctl.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

Index: linux-2.6/kernel/sysctl.c
===================================================================
--- linux-2.6.orig/kernel/sysctl.c
+++ linux-2.6/kernel/sysctl.c
@@ -1732,6 +1732,7 @@ static int __do_proc_dointvec(void *tbl_
int *i, vleft, first=1, neg, val;
unsigned long lval;
size_t left, len;
+ int ret = 0;

char buf[TMPBUFLEN], *p;
char __user *s = buffer;
@@ -1787,14 +1788,16 @@ static int __do_proc_dointvec(void *tbl_
s += len;
left -= len;

- if (conv(&neg, &lval, i, 1, data))
+ ret = conv(&neg, &lval, i, 1, data);
+ if (ret)
break;
} else {
p = buf;
if (!first)
*p++ = '\t';

- if (conv(&neg, &lval, i, 0, data))
+ ret = conv(&neg, &lval, i, 0, data);
+ if (ret)
break;

sprintf(p, "%s%lu", neg ? "-" : "", lval);
@@ -1823,11 +1826,9 @@ static int __do_proc_dointvec(void *tbl_
left--;
}
}
- if (write && first)
- return -EINVAL;
*lenp -= left;
*ppos += *lenp;
- return 0;
+ return ret;
#undef TMPBUFLEN
}


--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/