Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp682868pxy; Sat, 31 Jul 2021 22:20:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwUDA8UgQYdhCBFZAtGrBa45hkNg9ftv+AVilGl5Plwdz+48Lkp8S5SkEtUSI+xNlVIPzO X-Received: by 2002:a92:509:: with SMTP id q9mr575881ile.239.1627795221471; Sat, 31 Jul 2021 22:20:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627795221; cv=none; d=google.com; s=arc-20160816; b=dnN1Db4jWrElJ2OoTSk1Ce1uZIABckFhNrIW9UdN8D9nLtaCcgfO4GPGKZQ7rzqSDB 51SkFhA+DowXP3O0xpc/1UXv+rip2+vJsyctgOhnrO+6glDjEpl9sffpqyq5dSWlDqlg 6jRq6t7TbN3pv91IsTHlxg3JJE6NvxWQZatdYTlD2TyBF8YgzqPPxUbbFC40gTsVQFSq W+KNVHpgzUld1jiX9RQvhr/kmNtkjIBs9UWR1vqxLjLCxIUtuRUSFn6+0J37t8lMakBJ Y3chv+7uaIGbTsD4KShFKRBP1dpK2PWLPB0LF1iZB8VwSjksr5HBdRdUL1+pRB0Y/z5R Jj5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=k9qbYJLccHFJv4arTMHFUlD7rnXKKEvMEx8zxU+FSoE=; b=wQm4PDbRcUFxtuRcAFd/C05dud/XfkhsXJbuws/dFNxEfOho2FKYULHEd/zLbno1MR d2RDw0i2Q3hus6FoV+L3bJ5NKF5gHLc6p+i4K2rwdDPQtGQgQ3fL+o+1p6QEKzJwZ2fe aDpis/mxAtoGQ+sGQUPdZlqDFBKOb7vHMieSBdfLzh3LCWrvtc+vFgfSv3ky6zgSJWsz DpjX1+CdsOgMNpB3OMFwAS8LkYnASaqO45lwSVZxTvs5IH8BlGw7Uj7bh2lSOMobtBOm y/OuY4MpI4g+TOa4ZHuue02QcujX7xeK8EeCbcfnPS53rvAmpCwQy8+F+ffdrdrtvUJi 2fUg== 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 i187si7558007iof.20.2021.07.31.22.20.09; Sat, 31 Jul 2021 22:20:21 -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 S229804AbhHAFRI (ORCPT + 99 others); Sun, 1 Aug 2021 01:17:08 -0400 Received: from out30-133.freemail.mail.aliyun.com ([115.124.30.133]:42465 "EHLO out30-133.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbhHAFRH (ORCPT ); Sun, 1 Aug 2021 01:17:07 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;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=8;SR=0;TI=SMTPD_---0Uha9Xo1_1627795016; Received: from localhost(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0Uha9Xo1_1627795016) by smtp.aliyun-inc.com(127.0.0.1); Sun, 01 Aug 2021 13:16:57 +0800 From: Xianting Tian To: gregkh@linuxfoundation.org, jirislaby@kernel.org, amit@kernel.org, arnd@arndb.de Cc: linuxppc-dev@lists.ozlabs.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Xianting Tian Subject: [PATCH 2/2] virtio-console: remove unnecessary kmemdup() Date: Sun, 1 Aug 2021 13:16:55 +0800 Message-Id: <20210801051655.79048-1-xianting.tian@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 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, remove it. Fixes: 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