diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-10-26 08:45:53 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-10-26 08:45:53 +0200 |
commit | 45965252a29afc8ef6f58938077fe30f86081bf0 (patch) | |
tree | 25b61fd860652fd875aedbda93be2e05262f7ed3 | |
parent | 1177384179416c7136e1348f07609e0da1ae6b91 (diff) |
Revert "virtio-console: remove unnecessary kmemdup()"
This reverts commit 9db81eca10ba2d84177fa076704db3a5d76863c3.
A dependant patch on this one needs to be reverted, so this one also
needs to be reverted at this point in time.
Link: https://lore.kernel.org/r/208f7a41-a9fa-630c-cb44-c37c503f3a72@kernel.org
Reported-by: Jiri Slaby <jirislaby@kernel.org>
Cc: Xianting Tian <xianting.tian@linux.alibaba.com>
Cc: Shile Zhang <shile.zhang@linux.alibaba.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-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 4ed3ffb1d479..7eaf303a7a86 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -1117,6 +1117,8 @@ static int put_chars(u32 vtermno, const char *buf, int count) { struct port *port; struct scatterlist sg[1]; + void *data; + int ret; if (unlikely(early_put_chars)) return early_put_chars(vtermno, buf, count); @@ -1125,8 +1127,14 @@ static int put_chars(u32 vtermno, const char *buf, int count) if (!port) return -EPIPE; - sg_init_one(sg, buf, count); - return __send_to_port(port, sg, 1, count, (void *)buf, false); + data = kmemdup(buf, count, GFP_ATOMIC); + if (!data) + return -ENOMEM; + + sg_init_one(sg, data, count); + ret = __send_to_port(port, sg, 1, count, data, false); + kfree(data); + return ret; } /* |