Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1090484rwo; Wed, 2 Aug 2023 08:34:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlGM+z1F/spZWFUqrK3cmF0kuWnD5FmRfBrEqsCEmP3vwn4qi1ELvM7HFjJdxzkru+VXWJCE X-Received: by 2002:a05:6402:517a:b0:522:582c:f427 with SMTP id d26-20020a056402517a00b00522582cf427mr8069579ede.14.1690990464405; Wed, 02 Aug 2023 08:34:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690990464; cv=none; d=google.com; s=arc-20160816; b=SMno0SKQAcrTlt03PaTuMG4z2hcSWOz2ZsJW1Jaj5eoIsDggDanXnhZBWK1g+juau5 UUszQTw7cT/cbjCxPp3OOtfKbeeHsZoKeJTZZqxlNnwkRb8xoUmJjYHFSnozZ2hncVQN QJGg9aLCr47uyeX8rNtys7uV2kZnexnqZB3imdSpSYqzlxiIZlPcu92CfWDTVEY5hyeU 7pV/6h7Ww+Arw7uChMbxyBS7pKDFQQcwe5jH32wOC7bcgbRV220kLTMXqBiHNjJui+Bf ooh5nJeA1HZAPGXQJaqYQ4f9exrv7dywYkrNzZ2fiwfI12yrAWBYtG3zsreDsU3I/M+6 hq7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Lfsx7YMT1/nkAsgMqwMqDMIEJirhc7YJPrz4OW1nZfo=; fh=rfE2clVmEOjw46Hmq/OvSsQjzt1fonYxdQAFhNGYOhI=; b=Zp2nHY+KX/Bj0xA03QcY4tkMRWcFIUJY7F8Uj2NbTNYHtQGR8r93gk0LDqy5KUl/j+ eUwc2+X+JaIxMzTaE/9Kfgn+Qt/19+cYa5Vo3PxFdZrcjDNN6zyeeYzqWKJ2t3MUFqt3 2EF7TniscAKZzjuxk29OMWANMcD2ZisVfSMgNcC6vpLRKa4EzKa9tRQXelrzRpYU36Q0 05yqTDMhyfRcYcP4zFFW+ZO0XIfF3FqI/l1nDll4xV+pxcxIOYzL2uFerxBJrBT3J8nr tP2V9G4RmiyGhDeEttFaSP0eYF378DhKWdBgB72uOZe55QwIwA6TFiM/NCTWhwAis44J JLQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VxIurLA4; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b26-20020a05640202da00b005222117c6fasi10264254edx.614.2023.08.02.08.33.59; Wed, 02 Aug 2023 08:34:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VxIurLA4; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234151AbjHBOou (ORCPT + 99 others); Wed, 2 Aug 2023 10:44:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233665AbjHBOot (ORCPT ); Wed, 2 Aug 2023 10:44:49 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A1F52D4C for ; Wed, 2 Aug 2023 07:44:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690987440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Lfsx7YMT1/nkAsgMqwMqDMIEJirhc7YJPrz4OW1nZfo=; b=VxIurLA4qrQ+wbPu0x+guajx0AHZCKQC4h+wWsnO62d7qaQL8ruOxIXGiM4tmwL7P+4ir3 CjnO8C2SfFN+A0Nn4cXxRdF1ZmEv/7ErJ1EZKG7ZOiQdxKkTXyvjo8FtOrCLwvM9VgwSAp HWa3PDjF65s74OyX+fscA5kXcE0VkU8= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-574-mTic3aWOO7WXjzYQIN77zA-1; Wed, 02 Aug 2023 10:43:57 -0400 X-MC-Unique: mTic3aWOO7WXjzYQIN77zA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9E5A73806705; Wed, 2 Aug 2023 14:43:56 +0000 (UTC) Received: from pasta.redhat.com (unknown [10.45.225.145]) by smtp.corp.redhat.com (Postfix) with ESMTP id 019401121325; Wed, 2 Aug 2023 14:43:54 +0000 (UTC) From: Andreas Gruenbacher To: Andrew Morton Cc: Matthew Wilcox , David Sterba , linux-fsdevel@vger.kernel.org, Pankaj Raghav , Konstantin Komarov , ntfs3@lists.linux.dev, Theodore Tso , Jan Kara , linux-ext4@vger.kernel.org, Andreas Gruenbacher Subject: [PATCH] highmem: memcpy_{from,to}_folio() fix Date: Wed, 2 Aug 2023 16:43:54 +0200 Message-Id: <20230802144354.1023099-1-agruenba@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org memcpy_to_folio() and memcpy_from_folio() compute the size of the chunk of memory they can copy for each page, but then they don't use the chunk size in the actual memcpy. Fix that. Also, git rid of superfluous parentheses in these two functions. Fixes: 520a10fe2d72 ("highmem: add memcpy_to_folio() and memcpy_from_folio()") Signed-off-by: Andreas Gruenbacher --- include/linux/highmem.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 0280f57d4744..99c474de800d 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -445,13 +445,13 @@ static inline void memcpy_from_folio(char *to, struct folio *folio, VM_BUG_ON(offset + len > folio_size(folio)); do { - char *from = kmap_local_folio(folio, offset); + const char *from = kmap_local_folio(folio, offset); size_t chunk = len; if (folio_test_highmem(folio) && - (chunk > (PAGE_SIZE - offset_in_page(offset)))) + chunk > PAGE_SIZE - offset_in_page(offset)) chunk = PAGE_SIZE - offset_in_page(offset); - memcpy(to, from, len); + memcpy(to, from, chunk); kunmap_local(from); from += chunk; @@ -470,9 +470,9 @@ static inline void memcpy_to_folio(struct folio *folio, size_t offset, size_t chunk = len; if (folio_test_highmem(folio) && - (chunk > (PAGE_SIZE - offset_in_page(offset)))) + chunk > PAGE_SIZE - offset_in_page(offset)) chunk = PAGE_SIZE - offset_in_page(offset); - memcpy(to, from, len); + memcpy(to, from, chunk); kunmap_local(to); from += chunk; -- 2.40.1