fix pipe cleanup in do_write_buf()
authorMiklos Szeredi <miklos@szeredi.hu>
Mon, 8 Nov 2010 20:11:36 +0000 (21:11 +0100)
committerMiklos Szeredi <mszeredi@suse.cz>
Mon, 8 Nov 2010 20:11:36 +0000 (21:11 +0100)
lib/fuse_lowlevel.c

index f30156fa2e536746c0f6c3f36b1778a8a407b75f..2a5e8d26358eaa737775ac4048b7b3fc0b942fab 100644 (file)
@@ -1127,6 +1127,7 @@ static void do_write(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
 static void do_write_buf(fuse_req_t req, fuse_ino_t nodeid, const void *inarg,
                         const struct fuse_buf *ibuf)
 {
+       struct fuse_ll *f = req->f;
        struct fuse_buf buf = *ibuf;
        struct fuse_bufvec bufv = {
                .buf = &buf,
@@ -1157,15 +1158,16 @@ static void do_write_buf(fuse_req_t req, fuse_ino_t nodeid, const void *inarg,
        if (buf.size < arg->size) {
                fprintf(stderr, "fuse: do_write_buf: buffer size too small\n");
                fuse_reply_err(req, EIO);
-               return;
+               goto out;
        }
        buf.size = arg->size;
 
        req->f->op.write_buf(req, nodeid, &bufv, arg->offset, &fi);
 
+out:
        /* Need to reset the pipe if ->write_buf() didn't consume all data */
        if ((ibuf->flags & FUSE_BUF_IS_FD) && bufv.idx < bufv.count)
-               fuse_ll_clear_pipe(req->f);
+               fuse_ll_clear_pipe(f);
 }
 
 static void do_flush(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)