Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3208656pxb; Sat, 9 Oct 2021 04:51:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+luC6RPNyz2Mc4Nlp7/pM8ZUNTXC0Mns9gcDhQ8WfUxAARlSB2+A2K6GWNyQJbFarQub2 X-Received: by 2002:a17:90a:304:: with SMTP id 4mr18034247pje.124.1633780297761; Sat, 09 Oct 2021 04:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633780297; cv=none; d=google.com; s=arc-20160816; b=uBM3FVGBl9+bdvkzErod00p1sNgZ2EDXCS4LegPjg1PyrzrOBMhJ9nJor2BBSVQg0G 6sohtnZ8k+B4PX4vm6rWQqbSgAiGQWz2qwSkm5B17aL/v3ZkQd90gJX6K1EvMwLEDuUc CDmR7/vM0ZeNmTIYFrJU45ck80GUkG3cCbmAYB5Eg8lu8MC/MnIr6SRAjlACIw1VoYcE qdj+49kVgpuuR6htxBTUC5ClEZbar4Vwqf7yJz2iZSgKojKIPsSh+0nzKb4n3VLtuKeh MRmsMzKgyGv1Ex4l+PoY+h9wQuT6DiKOBkeOFSkNVARaEXjj/Wyr3emUZosxMr1uaUCi 7ucA== 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=DhFnL7UPvx532kgSQ3wsVTM2vhbODLrZpgl+c+HHYkRa+ub9sopuVxNwYQA2NsFFnu GDlWavmYM1c2LprWMI5XYR7br5ODoBSKUjIEywuizvpDyuBgwL4aF2IokSGDV6tq0gix uYU6cpLa8XA8fN//xP6axp+xVSV+pZ5HJmwF7Cma7h4jPtMPWAWNjBQG7u5Qo7V33asw DhMQeBBO6HrgJFINArOAxWPPDgbycH8bGgdKjv6HRKKbnIInDaqOBHqm9LSB6W+7b0gQ Q4hSCqlyytzTulwHAFIvoqRcTJEAgnA+hFrsPkNGzhsTywxYOcUvxu6wG8woLKwNePyW g2aw== 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 b18si2882567pld.172.2021.10.09.04.51.24; Sat, 09 Oct 2021 04:51:37 -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 S244753AbhJILuk (ORCPT + 99 others); Sat, 9 Oct 2021 07:50:40 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:55087 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232943AbhJILug (ORCPT ); Sat, 9 Oct 2021 07:50:36 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0Ur6QRPs_1633780116; Received: from localhost(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0Ur6QRPs_1633780116) by smtp.aliyun-inc.com(127.0.0.1); Sat, 09 Oct 2021 19:48:36 +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 v10 3/3] virtio-console: remove unnecessary kmemdup() Date: Sat, 9 Oct 2021 19:48:29 +0800 Message-Id: <20211009114829.1071021-4-xianting.tian@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211009114829.1071021-1-xianting.tian@linux.alibaba.com> References: <20211009114829.1071021-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