Skip to content

Commit

Permalink
9p: fix put_data error handling
Browse files Browse the repository at this point in the history
Abhishek Kulkarni pointed out an inconsistency in the way
errors are returned from p9_put_data.  On deeper exploration it
seems the error handling for this path was completely wrong.
This patch adds checks for allocation problems and propagates
errors correctly.

Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
  • Loading branch information
Eric Van Hensbergen committed Sep 24, 2008
1 parent 62aa528 commit 16ec470
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/9p/conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,15 +451,19 @@ p9_put_data(struct cbuf *bufp, const char *data, int count,
unsigned char **pdata)
{
*pdata = buf_alloc(bufp, count);
if (*pdata == NULL)
return -ENOMEM;
memmove(*pdata, data, count);
return count;
return 0;
}

static int
p9_put_user_data(struct cbuf *bufp, const char __user *data, int count,
unsigned char **pdata)
{
*pdata = buf_alloc(bufp, count);
if (*pdata == NULL)
return -ENOMEM;
return copy_from_user(*pdata, data, count);
}

Expand Down

0 comments on commit 16ec470

Please sign in to comment.