virtio_console: Free buffer if splice fails
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>
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 6a36994..09d193d 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -881,6 +881,8 @@
if (likely(ret > 0))
ret = send_pages(port, sgl.sg, sgl.n, sgl.len, true);
+ if (unlikely(ret <= 0))
+ kfree(sgl.sg);
return ret;
}