Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp246212pxt; Fri, 6 Aug 2021 00:34:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGl8JaXgUZz8cbUgXdSs7VnrniwGqWab/CMcmOi8jYGHOO6GLOqeDCSMCsC1Q1v+/GnOHz X-Received: by 2002:a6b:7012:: with SMTP id l18mr963773ioc.44.1628235297152; Fri, 06 Aug 2021 00:34:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628235297; cv=none; d=google.com; s=arc-20160816; b=zruXLOSdUIZECxVt4WoqcCFdJ3wAZ2rqcxFEM3sszUUOcg5q+9dw1vv+/Q5hohn7Pq Yjihj3TIeXXoaToCBwttBtTj+SpTSGVENSZNvSihul2E667poakLw/8zv+LlSgeFBaXv qW0pHl05avhxWp2WAfiA+7mouuHip/RlEn4ra6IUaYGhqNq1n+4NXOPAIJJKxbwM321Y K2ip04TtYL/2RnJG81Ryl0PbtNcaxlkWPhqzDFi50G601wB7xOBqLzwm3pj3+je++msx wgqlg95XfiMPs7xelD9BjeryDidIk/WFQgWzOdCrc7uyDrZAhUB7ytB9aEHPrSRMNWbd luwQ== 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=pXvzfi4AYa8Ze5aR2qvgYlIhe8mVA1wjk1vQLOfSAeCd4vYTIAZxqvZKJMERvqrkef UndNqMsU3KSAoQgtEbYI836+kpFYiGF2tzlSbOzyZHVtKJ/8ILfq6C9wFO+zyXE4Saqu 9uVQSuG61FQNgR4nUo1i7NLwOh9TXj9nw2expORi9ehusvVqF0CFf9HHFpKpLLipxlJb yfb7qTd2N9UZu6aA5xiy68357pvqNRorGDLDSXsolapQG+ArXKiE0XtLAw6DzCLjQn64 imQSmHv5fVAcOtmclkm73tbWiWcGSALkQ16Blh+KkxRqbNJERaKsKNxH8wOegpNrplvG AKGQ== 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 l6si8304791ilg.44.2021.08.06.00.34.45; Fri, 06 Aug 2021 00:34:57 -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 S240910AbhHFDCL (ORCPT + 99 others); Thu, 5 Aug 2021 23:02:11 -0400 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:40471 "EHLO out4436.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239122AbhHFDCJ (ORCPT ); Thu, 5 Aug 2021 23:02:09 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0Ui5GmbZ_1628218901; Received: from localhost(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0Ui5GmbZ_1628218901) by smtp.aliyun-inc.com(127.0.0.1); Fri, 06 Aug 2021 11:01:41 +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, guoren@kernel.org, Xianting Tian Subject: [PATCH v4 2/2] virtio-console: remove unnecessary kmemdup() Date: Fri, 6 Aug 2021 11:01:38 +0800 Message-Id: <20210806030138.123479-3-xianting.tian@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210806030138.123479-1-xianting.tian@linux.alibaba.com> References: <20210806030138.123479-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