Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp218539pxb; Fri, 15 Oct 2021 04:15:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxb/uRRIskpSaLHdUdgYxnY2wkzPTcASVUxAM+QKzZIjcQUK9NLS3q0hznmYj34rGx3Ajw X-Received: by 2002:a17:90b:4f90:: with SMTP id qe16mr13276257pjb.137.1634296507623; Fri, 15 Oct 2021 04:15:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634296507; cv=none; d=google.com; s=arc-20160816; b=v82vcTjkIIpDWMFd4mWlEIhSRAq8lsU7eTOC1p6MVBQcMivq2cknI8co4yEwaVVNR7 prlPYaKWfCWngmCYXFEQEmmNXiNW1aPNSDGb0cbZUmtPRs7QCRQMoNxNBk54eSzFQKno It2iKMWjL5JvwlEJTnYq9pTG2dlK/+fcai3WLWYjgufNYjKMBedM1QGHxVJ0qTpVWeuC wF+AGQXZLV4LmKefUtrvvVj6WfKWDXHFw+xaQkLr76gBvmh3SwGFOsi/ZDJ0PqEE/aDC bd0vr3o0iENnf4dqN3qaSscNvd81j0M6G5WneRJZv0qHUEpO0fKVF/oYhv80CBdHwhUI anmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=GzFSMusP4bfk1A5PE+fVLC5XNtqF7KjCP6nVDsX7uX0=; b=emeXCj7kweX6nelVEVs4l7pKweb0DuBSZAjqVqaUDCAzbLkvkcxyEkVGyIlqCX0NE1 RbKjc/QMuQRktcH6ldZhB6ypvCdRMMxxlRHeLS5D5QvGQEncdaicEOtSpgLHi3XoKLSf 7vngFyJ1sOXBs/mmacXcsovvfWbI5qx76e3rJNccpuQnQG7IIYsJ2jYX2atH0s821A6V 8y7fuch49QyVkTFmiLBiayY18QHyFVDs70wveLwJx/09NRNrOczKxJxiB+T3Q3H8OqS4 WsYMgdCulwC/Oo700zAFp/srR7QQto7WvNrSLAR6Q6Qe1cGeouGl1N+N2AINOZtj2ey7 qZOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si8819678plx.247.2021.10.15.04.14.55; Fri, 15 Oct 2021 04:15:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233210AbhJOCtO (ORCPT + 99 others); Thu, 14 Oct 2021 22:49:14 -0400 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:33805 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233054AbhJOCtL (ORCPT ); Thu, 14 Oct 2021 22:49:11 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R311e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01424;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0Us01OPT_1634266022; Received: from localhost(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0Us01OPT_1634266022) by smtp.aliyun-inc.com(127.0.0.1); Fri, 15 Oct 2021 10:47:03 +0800 From: Xianting Tian To: gregkh@linuxfoundation.org, jirislaby@kernel.org, amit@kernel.org, arnd@arndb.de, osandov@fb.com Cc: shile.zhang@linux.alibaba.com, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Xianting Tian Subject: [PATCH v11 3/3] virtio-console: remove unnecessary kmemdup() Date: Fri, 15 Oct 2021 10:46:58 +0800 Message-Id: <20211015024658.1353987-4-xianting.tian@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211015024658.1353987-1-xianting.tian@linux.alibaba.com> References: <20211015024658.1353987-1-xianting.tian@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This revert commit c4baad5029 ("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 Reviewed-by: Shile Zhang --- drivers/char/virtio_console.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 7eaf303a7..4ed3ffb1d 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -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); } /* -- 2.17.1