diff options
-rw-r--r-- | drivers/char/virtio_console.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 6266c0568e1d..e9b7e0b3cabe 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -1136,6 +1136,8 @@ static int put_chars(u32 vtermno, const char *buf, int count) | |||
1136 | { | 1136 | { |
1137 | struct port *port; | 1137 | struct port *port; |
1138 | struct scatterlist sg[1]; | 1138 | struct scatterlist sg[1]; |
1139 | void *data; | ||
1140 | int ret; | ||
1139 | 1141 | ||
1140 | if (unlikely(early_put_chars)) | 1142 | if (unlikely(early_put_chars)) |
1141 | return early_put_chars(vtermno, buf, count); | 1143 | return early_put_chars(vtermno, buf, count); |
@@ -1144,8 +1146,14 @@ static int put_chars(u32 vtermno, const char *buf, int count) | |||
1144 | if (!port) | 1146 | if (!port) |
1145 | return -EPIPE; | 1147 | return -EPIPE; |
1146 | 1148 | ||
1147 | sg_init_one(sg, buf, count); | 1149 | data = kmemdup(buf, count, GFP_ATOMIC); |
1148 | return __send_to_port(port, sg, 1, count, (void *)buf, false); | 1150 | if (!data) |
1151 | return -ENOMEM; | ||
1152 | |||
1153 | sg_init_one(sg, data, count); | ||
1154 | ret = __send_to_port(port, sg, 1, count, data, false); | ||
1155 | kfree(data); | ||
1156 | return ret; | ||
1149 | } | 1157 | } |
1150 | 1158 | ||
1151 | /* | 1159 | /* |