Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1684929pxb; Thu, 28 Oct 2021 08:13:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYqpW3qK04Qm1+ElBdYhq/FHek0ExYGBOG8eJMEkE0dwoYTdGu+rrGhOzcH7sOSRIrP4le X-Received: by 2002:a7b:c010:: with SMTP id c16mr5138683wmb.141.1635433994540; Thu, 28 Oct 2021 08:13:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635433994; cv=none; d=google.com; s=arc-20160816; b=ZdcAPnNcgsKewfXNsvw55B9xlYFPv5tYwwYPUxX6i+/vGWHZGpuAb7s1FG2Nt1oGTl GkarM7N/xk8volXbkkZXw0JtkNfa6ZeL0atVzOZLMtqDiYGrsl/QRdmDWRQ6Dp8dFZgC vIAx4f64R939TmgBdlh3chgROemysXOkeudAU6hnezS7nPS6kvi1Z1JiNTdtgz8K5ykm QGgu4215XEk3T18DgPZcI2QFiMZwMcu/KZvxl5k9NQLv4sppUXhcAZBu99sV/vITmvi9 wbyRlipB2/NyA8FfobPowFtsv7gYtzu602oyEwraFdVDB9AUI61nykX0yLUihcIlr3bI /AKQ== 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=aJX19a7iWGgsWpbXnXJkw2dh5r7J7eUxnkieruhtLc8QJmbwaVf/5ozttsRl7npkD1 KtBcfimHiAii5SQs600S+I210Z6nMOx1rihBsNkR6+OVUu//BszsJesK+neEgYJPrh/6 dsdKOI/AjBZe8Zj9gELjyEFMcBXFnaD9Q1Q5jGht1DFUMbWf6BBRrTMysUU15gMBvV33 hPGS8X1jB4okHPZOgnFtGCqE/nsvcg4IhVqxj5mBQD0CWcqD/rlmkvzIdyuGzcIJsJEr 2ZXs47ALa/BBNoM581sTwBMdMgOdpvGvsToZd+jESxqMQ+2oHsqAzjIkyks6LQFKV0de Cl0w== 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 q15si5358565edd.240.2021.10.28.08.12.49; Thu, 28 Oct 2021 08:13:14 -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 S231404AbhJ1PMg (ORCPT + 99 others); Thu, 28 Oct 2021 11:12:36 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:57361 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230265AbhJ1PM1 (ORCPT ); Thu, 28 Oct 2021 11:12:27 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04407;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0Uu0vwYK_1635433797; Received: from localhost(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0Uu0vwYK_1635433797) by smtp.aliyun-inc.com(127.0.0.1); Thu, 28 Oct 2021 23:09:57 +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, sfr@canb.auug.org.au, linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Xianting Tian Subject: [PATCH v12 2/2] virtio-console: remove unnecessary kmemdup() Date: Thu, 28 Oct 2021 23:09:54 +0800 Message-Id: <20211028150954.1356334-3-xianting.tian@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211028150954.1356334-1-xianting.tian@linux.alibaba.com> References: <20211028150954.1356334-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