浏览代码

9p: fix put_data error handling

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>
Eric Van Hensbergen 17 年之前
父节点
当前提交
16ec470012
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      net/9p/conv.c

+ 5 - 1
net/9p/conv.c

@@ -451,8 +451,10 @@ p9_put_data(struct cbuf *bufp, const char *data, int count,
 		   unsigned char **pdata)
 		   unsigned char **pdata)
 {
 {
 	*pdata = buf_alloc(bufp, count);
 	*pdata = buf_alloc(bufp, count);
+	if (*pdata == NULL)
+		return -ENOMEM;
 	memmove(*pdata, data, count);
 	memmove(*pdata, data, count);
-	return count;
+	return 0;
 }
 }
 
 
 static int
 static int
@@ -460,6 +462,8 @@ p9_put_user_data(struct cbuf *bufp, const char __user *data, int count,
 		   unsigned char **pdata)
 		   unsigned char **pdata)
 {
 {
 	*pdata = buf_alloc(bufp, count);
 	*pdata = buf_alloc(bufp, count);
+	if (*pdata == NULL)
+		return -ENOMEM;
 	return copy_from_user(*pdata, data, count);
 	return copy_from_user(*pdata, data, count);
 }
 }