]> git.baikalelectronics.ru Git - kernel.git/commitdiff
virtio-console: remove unnecessary kmemdup()
authorXianting Tian <xianting.tian@linux.alibaba.com>
Fri, 15 Oct 2021 02:46:58 +0000 (10:46 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 21 Oct 2021 08:35:04 +0000 (10:35 +0200)
This revert commit e9e71a1f00 ("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: Xianting Tian <xianting.tian@linux.alibaba.com>
Reviewed-by: Shile Zhang <shile.zhang@linux.alibaba.com>
Link: https://lore.kernel.org/r/20211015024658.1353987-4-xianting.tian@linux.alibaba.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/virtio_console.c

index 7eaf303a7a86f9230ad3b2d906eaacbf211589a3..4ed3ffb1d47909c18d976025967d8f37ba362bd3 100644 (file)
@@ -1117,8 +1117,6 @@ 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);
@@ -1127,14 +1125,8 @@ static int put_chars(u32 vtermno, const char *buf, int count)
        if (!port)
                return -EPIPE;
 
-       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;
+       sg_init_one(sg, buf, count);
+       return __send_to_port(port, sg, 1, count, (void *)buf, false);
 }
 
 /*