Commit 9db81eca authored by Xianting Tian's avatar Xianting Tian Committed by Greg Kroah-Hartman

virtio-console: remove unnecessary kmemdup()

This revert commit c4baad50 ("virtio-console: avoid DMA from stack")

hvc framework will never pass stack memory to the put_chars() function,
So the calling of kmemdup() is unnecessary, we can remove it.
Signed-off-by: default avatarXianting Tian <xianting.tian@linux.alibaba.com>
Reviewed-by: default avatarShile Zhang <shile.zhang@linux.alibaba.com>
Link: https://lore.kernel.org/r/20211015024658.1353987-4-xianting.tian@linux.alibaba.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0986d7bc
...@@ -1117,8 +1117,6 @@ static int put_chars(u32 vtermno, const char *buf, int count) ...@@ -1117,8 +1117,6 @@ static int put_chars(u32 vtermno, const char *buf, int count)
{ {
struct port *port; struct port *port;
struct scatterlist sg[1]; struct scatterlist sg[1];
void *data;
int ret;
if (unlikely(early_put_chars)) if (unlikely(early_put_chars))
return early_put_chars(vtermno, buf, count); return early_put_chars(vtermno, buf, count);
...@@ -1127,14 +1125,8 @@ static int put_chars(u32 vtermno, const char *buf, int count) ...@@ -1127,14 +1125,8 @@ static int put_chars(u32 vtermno, const char *buf, int count)
if (!port) if (!port)
return -EPIPE; return -EPIPE;
data = kmemdup(buf, count, GFP_ATOMIC); sg_init_one(sg, buf, count);
if (!data) return __send_to_port(port, sg, 1, count, (void *)buf, false);
return -ENOMEM;
sg_init_one(sg, data, count);
ret = __send_to_port(port, sg, 1, count, data, false);
kfree(data);
return ret;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment