Commit 622c36a6 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] openpromfs property_read() fix

openpromfs property_read() is slightly abused by property_write() - the
latter calls property_read(file, NULL, 0, NULL) if we still hadn't done
any IO on that file; property_read() will do setup work and, since it's
called with count equal to 0, do nothing else.

That stopped working - now we check if *ppos is sane before doing
anything else and that, of course, oopses.  Trivial fix is to move the
check past that for count == 0...
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.theplanet.co.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 00acc832
......@@ -94,8 +94,6 @@ static ssize_t property_read(struct file *filp, char __user *buf,
openprom_property *op;
char buffer[64];
if (*ppos >= 0xffffff || count >= 0xffffff)
return -EINVAL;
if (!filp->private_data) {
node = nodes[(u16)((long)inode->u.generic_ip)].node;
i = ((u32)(long)inode->u.generic_ip) >> 16;
......@@ -168,6 +166,8 @@ static ssize_t property_read(struct file *filp, char __user *buf,
op = (openprom_property *)filp->private_data;
if (!count || !(op->len || (op->flag & OPP_ASCIIZ)))
return 0;
if (*ppos >= 0xffffff || count >= 0xffffff)
return -EINVAL;
if (op->flag & OPP_STRINGLIST) {
for (k = 0, p = op->value; p < op->value + op->len; p++)
if (!*p)
......
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