Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp438686pxt; Thu, 12 Aug 2021 01:55:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxokduosWMvI36dDiZPFkHokraRVgX/ahiXrDeQcC2qrthtumEMN02VlqOYgRqS7mgArYOT X-Received: by 2002:a17:906:8047:: with SMTP id x7mr2676358ejw.453.1628758509479; Thu, 12 Aug 2021 01:55:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628758509; cv=none; d=google.com; s=arc-20160816; b=HFBLj5hkkPncVPYWT4tkijzbS+nTU6eYUMmzyvxtjdE8auYJ1xlelcmf9dKyLkUF6s faoGtubeC3NFx3BdOoDCFhS+F9AZceTKo9B1k6ddVx4wrQlMpZ1+zcs7788eP5v96FOg oPG/V4GIL6FM9tKvgVgKwbeDIE7SIfZxE4RHStCLmpfEhkvpUrhYWxjSOdZZL/MAo93z JN4/KI24+0vcbN/Jiz1VpPVMe2Uc51cceBE0OvBzicTWZW1VmzH+wponILEHdU/PeHTi zKjdvfqovtqbA6LiIyYoUzqa5cNo9cWtbMj5RI42MEyHCFG9r5aEO9vMdpLS9ooZHpzO nvmw== 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=S6RKdO3giISjXgCB/5ZteNWxVXO69lulswtM0+4LqSM=; b=OnItUp805jG8clchM/2frDj4y8+epkyGkrsjbjGdGsysyWIy4ue5VTjwbUeWG/SC17 K5s7lOSxFbxQXH8eigD/yDZMYbpDSRlHv7ErCZ9TaKeBsvkelqh6Ws38HTWuT0DUnU+1 oyLenyGYL+ew3pUptgYX5ujTiojlUImkmTgddnvvwOwzCODyifmdW8GNHxd0bCJdIHjt TpWQL+I0LOj7FJViROkBKPfZF1l9dgfAlrjKmJY4YYn/lVdRtvknGn5S38ieDjc7xQAG zJJhkW8pce1KgDzdfqJBMItCRNo5X2FyA7dNzpat6Y/JO4LbXo8MEhdO6VPl/r1D8Eg8 bN4A== 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 s24si2179576ejd.649.2021.08.12.01.54.46; Thu, 12 Aug 2021 01:55:09 -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 S234768AbhHLIwS (ORCPT + 99 others); Thu, 12 Aug 2021 04:52:18 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:46608 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233666AbhHLIwQ (ORCPT ); Thu, 12 Aug 2021 04:52:16 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R381e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04423;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0Uim9beb_1628758275; Received: from localhost(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0Uim9beb_1628758275) by smtp.aliyun-inc.com(127.0.0.1); Thu, 12 Aug 2021 16:51:15 +0800 From: Xianting Tian To: gregkh@linuxfoundation.org, jirislaby@kernel.org, amit@kernel.org, arnd@arndb.de, osandov@fb.com Cc: linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, guoren@kernel.org, Xianting Tian Subject: [PATCH v5 2/2] virtio-console: remove unnecessary kmemdup() Date: Thu, 12 Aug 2021 16:51:12 +0800 Message-Id: <20210812085112.145265-3-xianting.tian@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210812085112.145265-1-xianting.tian@linux.alibaba.com> References: <20210812085112.145265-1-xianting.tian@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hvc framework will never pass stack memory to the put_chars() function, So the calling of kmemdup() is unnecessary, we can remove it. This revert commit c4baad5029 ("virtio-console: avoid DMA from stack") Signed-off-by: Xianting Tian --- 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