Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1205534pxb; Tue, 17 Aug 2021 06:24:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFhJ4p+xm/gC6r2J56fXTbQn/ZEMdrYJ4qAgPYjvw+Jgp2MvF4dCYB9+XCwERL2u2qMHIu X-Received: by 2002:a5d:9693:: with SMTP id m19mr2857663ion.181.1629206688173; Tue, 17 Aug 2021 06:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629206688; cv=none; d=google.com; s=arc-20160816; b=SWPgJyOlaL3E2xsfBZmorpxzYQK81phqW2SSbnvaq9+Ztm9+d8mNTnMmzcGrFF83Y4 Ksd9v1GaDLToJDuZeNLPwoU/6I7i4xniPQMV6JeflSZl28m4QH35BYdVDpPMp+88tyMQ RDx9IdZhIFV+y9vtO8Fgr2l1/IwQuC0+oUXS/nREbEaVUHtp8mU6yztnReysE09aYO6Q dFQKeJ3iDb/27B30oj7DbxhPdx2teKfWlMB+vTRaPKtXpDWO8me6JwtvlSVshhbA3uuT RfKRtO/ug3lIsjLNWdV6YxP1fmkMVojl+RNZUCl0aXZF9VXDHsrdPHkZ61PnjhsyZY0F LN0g== 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=dH/WbOE4cALCWwN7EIEhsvyrxszqouBJuFuDfrBtdN9+1kSQpc1GEzUAwVoM0w5BpV /mJa9BYtoYPpDPL94gVXJRwKXd4UVICqPvW4VhOOrZlvCuC62cQ3bX4H/iXH9SGk4XAI rvIFK1D9aA1N554pzuyT0FrdmQBhk0t66egjQyK6iFf3KH3jgADRtjKH4lAFd3sk9blJ 9OOlw0cNfBuBlbl0CoGKv5YVwnITSrjJYSBM40ciFSLzJ3JVx2a88+elvwAsIemh7bw/ AKRuZBr9kh+4lKyiIARjl+F3gG2MsVIBspRcqkitzi1u0of2+sAUDiFxTNkSCwWcEbZw 1AVg== 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 t17si2388450ilp.119.2021.08.17.06.24.36; Tue, 17 Aug 2021 06:24:48 -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 S239905AbhHQNYP (ORCPT + 99 others); Tue, 17 Aug 2021 09:24:15 -0400 Received: from out30-131.freemail.mail.aliyun.com ([115.124.30.131]:41823 "EHLO out30-131.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240054AbhHQNYN (ORCPT ); Tue, 17 Aug 2021 09:24:13 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R731e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04395;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0UjQQjQ9_1629206583; Received: from localhost(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0UjQQjQ9_1629206583) by smtp.aliyun-inc.com(127.0.0.1); Tue, 17 Aug 2021 21:23:03 +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, Xianting Tian Subject: [PATCH v7 2/2] virtio-console: remove unnecessary kmemdup() Date: Tue, 17 Aug 2021 21:23:00 +0800 Message-Id: <20210817132300.165014-3-xianting.tian@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210817132300.165014-1-xianting.tian@linux.alibaba.com> References: <20210817132300.165014-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