Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp259017pxb; Wed, 18 Aug 2021 01:26:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkUqEPk0neyZrN/lOMOwXndjByg+sa8T5u6KF294aXMKNP5p3krFMzuLjMRMYDMPLu0fxV X-Received: by 2002:a17:906:3c10:: with SMTP id h16mr8736217ejg.205.1629275195366; Wed, 18 Aug 2021 01:26:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629275195; cv=none; d=google.com; s=arc-20160816; b=rAEMOMsDnIDxV/qR7iVoO3RaGqKmEYstq6WeSKR2iJT9BqB1hjAM9fZvRwvybSYla9 jZsjEBT2g6dGM9JjNT1TkTX8VNeloKL2HknsQb4Fu+euj2prgrok2VLMHy6TicYmX1Fq PFiKHXi/H7u2UZz4HfsriMl7gVqsMmCHYchMUQhUI9kpldvUbCJDPCsRVBBkh9KUrwJv 2KGrTRGPvtjS3IszTFsszvK/GX9gmHAsWbnHBQnYgbJfpQpzUEATpcmcv80LTPVcI+Rf CshF6QG2PU4ARUxpYCZL+rD0RWR/6cTGSnBpM9NIajs1YaOcKkisdkUZ49NoF/ZmXefg iUng== 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=FlBmIHkg4Pk5FstKnGIg81UqsvU01LzZNHRiHAPiAYUtGpriYKg1m/jsBE2XXNgdeH PUjRUz0gDQuGKn3sTWo2MGNAWFgvkSTQZRJir6IcfZueo6nTNzNEOM4TRv1GwKx5t+t9 4xTDv9zidk6Rj716XqXk4iE2nIP/75FHkwzc1ZxzwZ5JAgJfqEH6zm+YXe+T4kqLgCIz yJpiJu98vh+64Mi+oWPycRQeuZ+h/FCsZgPtTI9DmDrfXdRyETRVN5sk58i5o9Bzuqvb o4mD57YkXwhEabDPHPhJgSv7KX4cwUGaZhVX3Fv8aC9vuatZ3MIZmtBrwjQ8o6jYGzch mLXQ== 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 s8si5362365edx.49.2021.08.18.01.26.12; Wed, 18 Aug 2021 01:26:35 -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 S239616AbhHRIWs (ORCPT + 99 others); Wed, 18 Aug 2021 04:22:48 -0400 Received: from out30-44.freemail.mail.aliyun.com ([115.124.30.44]:41458 "EHLO out30-44.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239585AbhHRIWo (ORCPT ); Wed, 18 Aug 2021 04:22:44 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;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_---0UjgHpxJ_1629274886; Received: from localhost(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0UjgHpxJ_1629274886) by smtp.aliyun-inc.com(127.0.0.1); Wed, 18 Aug 2021 16:21:26 +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 v8 3/3] virtio-console: remove unnecessary kmemdup() Date: Wed, 18 Aug 2021 16:21:22 +0800 Message-Id: <20210818082122.166881-4-xianting.tian@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210818082122.166881-1-xianting.tian@linux.alibaba.com> References: <20210818082122.166881-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