Skip to content

Commit

Permalink
i2o: check return code from put_user()
Browse files Browse the repository at this point in the history
Check return value of put_user() and return -EFAULT if it failed.
Original comment "We did a get user...so assuming mem is ok...is this
bad?" is incorrect because memory can be read only.

Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Kulikov Vasiliy authored and Linus Torvalds committed Aug 11, 2010
1 parent d929dc2 commit 89596f2
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions drivers/message/i2o/i2o_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ static int i2o_cfg_gethrt(unsigned long arg)

len = 8 + ((hrt->entry_len * hrt->num_entries) << 2);

/* We did a get user...so assuming mem is ok...is this bad? */
put_user(len, kcmd.reslen);
if (len > reslen)
if (put_user(len, kcmd.reslen))
ret = -EFAULT;
else if (len > reslen)
ret = -ENOBUFS;
else if (copy_to_user(kcmd.resbuf, (void *)hrt, len))
ret = -EFAULT;
Expand Down Expand Up @@ -147,8 +147,9 @@ static int i2o_cfg_getlct(unsigned long arg)
lct = (i2o_lct *) c->lct;

len = (unsigned int)lct->table_size << 2;
put_user(len, kcmd.reslen);
if (len > reslen)
if (put_user(len, kcmd.reslen))
ret = -EFAULT;
else if (len > reslen)
ret = -ENOBUFS;
else if (copy_to_user(kcmd.resbuf, lct, len))
ret = -EFAULT;
Expand Down Expand Up @@ -208,8 +209,9 @@ static int i2o_cfg_parms(unsigned long arg, unsigned int type)
return -EAGAIN;
}

put_user(len, kcmd.reslen);
if (len > reslen)
if (put_user(len, kcmd.reslen))
ret = -EFAULT;
else if (len > reslen)
ret = -ENOBUFS;
else if (copy_to_user(kcmd.resbuf, res, len))
ret = -EFAULT;
Expand Down

0 comments on commit 89596f2

Please sign in to comment.