net/9p: Return error if we fail to encode protocol data
authorAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Tue, 19 Oct 2010 03:47:02 +0000 (09:17 +0530)
committerEric Van Hensbergen <ericvh@gmail.com>
Thu, 28 Oct 2010 14:08:49 +0000 (09:08 -0500)
We need to return error in case we fail to encode data in protocol buffer.
This patch also return error in case of a failed copy_from_user.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
net/9p/client.c
net/9p/protocol.c

index bc7b03537699dea93a578a879d5f991fec61ed8b..e3cfdff373273944f3e0abac1a8798ab0ef1154a 100644 (file)
@@ -579,6 +579,8 @@ p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...)
        va_start(ap, fmt);
        err = p9pdu_vwritef(req->tc, c->proto_version, fmt, ap);
        va_end(ap);
+       if (err)
+               goto reterr;
        p9pdu_finalize(req->tc);
 
        err = c->trans_mod->request(c, req);
index 3acd3afb20c857f6f3d2451a6ce1d7ba5c14af76..45c15f491401c017f8fa423b465f3c910de08685 100644 (file)
@@ -122,9 +122,8 @@ static size_t
 pdu_write_u(struct p9_fcall *pdu, const char __user *udata, size_t size)
 {
        size_t len = MIN(pdu->capacity - pdu->size, size);
-       int err = copy_from_user(&pdu->sdata[pdu->size], udata, len);
-       if (err)
-               printk(KERN_WARNING "pdu_write_u returning: %d\n", err);
+       if (copy_from_user(&pdu->sdata[pdu->size], udata, len))
+               len = 0;
 
        pdu->size += len;
        return size - len;