virtio_console: Free buffer if splice fails
authorSjur Brændeland <sjur.brandeland@stericsson.com>
Mon, 15 Oct 2012 07:57:33 +0000 (09:57 +0200)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 18 Dec 2012 04:50:39 +0000 (15:20 +1030)
Free the allocated scatter list if send_pages fails in function
port_splice_write.

Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/char/virtio_console.c

index 6a36994..09d193d 100644 (file)
@@ -881,6 +881,8 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
        if (likely(ret > 0))
                ret = send_pages(port, sgl.sg, sgl.n, sgl.len, true);
 
+       if (unlikely(ret <= 0))
+               kfree(sgl.sg);
        return ret;
 }