mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] 9p: fix put_data error handling
@ 2008-09-23 21:50 Eric Van Hensbergen
  0 siblings, 0 replies; only message in thread
From: Eric Van Hensbergen @ 2008-09-23 21:50 UTC (permalink / raw)
  To: Abhishek Kulkarni; +Cc: v9fs-developer, linux-kernel

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>
---
 net/9p/conv.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/net/9p/conv.c b/net/9p/conv.c
index 4454720..5ad3a3b 100644
--- a/net/9p/conv.c
+++ b/net/9p/conv.c
@@ -451,8 +451,10 @@ 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
@@ -460,6 +462,8 @@ 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);
 }

--
1.5.4.3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-09-23 21:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-23 21:50 [PATCH] 9p: fix put_data error handling Eric Van Hensbergen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®