Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp486379pxt; Thu, 12 Aug 2021 03:10:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/MJsf9CN0JGmwIJs2lYcmOn+IpF/TnbJ+K6Dirw/mquBKEOCCIt2V3QcddKa9MkVNRs88 X-Received: by 2002:a92:d112:: with SMTP id a18mr2248109ilb.34.1628763053013; Thu, 12 Aug 2021 03:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628763053; cv=none; d=google.com; s=arc-20160816; b=cNwfDhl6GuJtxCfF461cclwLQMZwAD+QID56mtb3ILb/l9Ha4ISxebGDI6hvlO1B92 9CCPmt1ucaVwOBJUwNeFMyR3VexQea6JSd6FJ7EqkZNBENCDImNGDlHLAIsNsFNVH8er hh0rrRnXZCMb2It7oWPOvx1CwapTXy3g8epAHp1dli7x7DRHDSKVTSKOba523djQNsCJ UkqrBBtvNU37V0dRtgRj7Em8zC2q2ij55hKPvO5ST3mIA2QJxhURtewYTJTjPEELyHr6 cKdlCEB1B2Y24Z1GYSY6R97ANK0ELvFmjqMZj1ShaqL16KO1zH4TU2FuuhAAEk7NRA0f yTEA== 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=pTqx2SUjRQ7DvEMGLSUHtaKlWGfjBUkPZhw5GbFMSTAoJD13ZG5A5T9rkIW+wgFCfj Y2tdV3LQL2o+Q0ASNPA4enTAg+2uMiN3YA9mdWBnAhV0IYUQyk1ENnklMRrkNcee5bR9 9zv82uiyV3ymvtB0n/HAkBitY7Z+TJaIwFKtbeSFADIYikbbzsOQWCuQ406sEKsHhtZT 7LeD3eCT8Y2nUYx+70M9G8bbYlXRj9LomwkdBp5I5fCSoepEqJRXv9xM+c4tBxyVYSR3 bazwaJ4F43GD8zeWR2al6hIAIyZyEnKlptOSQRlfwIE/7e9t4cyZxfVbFEyeHvWv1VSn +d+w== 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 v19si2754843jat.96.2021.08.12.03.10.42; Thu, 12 Aug 2021 03:10:53 -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 S236308AbhHLJqn (ORCPT + 99 others); Thu, 12 Aug 2021 05:46:43 -0400 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:56152 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236304AbhHLJqh (ORCPT ); Thu, 12 Aug 2021 05:46:37 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R411e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=alimailimapcm10staff010182156082;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0Uimacum_1628761535; Received: from localhost(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0Uimacum_1628761535) by smtp.aliyun-inc.com(127.0.0.1); Thu, 12 Aug 2021 17:45:35 +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 v6 2/2] virtio-console: remove unnecessary kmemdup() Date: Thu, 12 Aug 2021 17:45:32 +0800 Message-Id: <20210812094532.145497-3-xianting.tian@linux.alibaba.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210812094532.145497-1-xianting.tian@linux.alibaba.com> References: <20210812094532.145497-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