From patchwork Wed Aug 2 14:43:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Gruenbacher X-Patchwork-Id: 13338259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5351CC001E0 for ; Wed, 2 Aug 2023 14:44:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234321AbjHBOox (ORCPT ); Wed, 2 Aug 2023 10:44:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233665AbjHBOov (ORCPT ); Wed, 2 Aug 2023 10:44:51 -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 156C8E0 for ; Wed, 2 Aug 2023 07:44:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1690987442; 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=ZDl3eriLs9LZhkNlVclb9zL0v80Kmrb/PL8gYHlRxPYbH9hAT59RBP5snjJvh6uGUPVcYz bZWp0UqBafa7Q8VErKPQ4edAZNAInvHfOeguW4CXVUtwihVAwwHB/63D/0XBonyXqXUyVX GnpMAzCJvdGXEupw5z5KbUoWpdbcDVQ= 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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;