highmem: fix a memory copy problem in memcpy_from_folio

Message ID 20231130034017.1210429-1-suhui@nfschina.com
State New
Headers
Series highmem: fix a memory copy problem in memcpy_from_folio |

Commit Message

Su Hui Nov. 30, 2023, 3:40 a.m. UTC
  Clang static checker complains that value stored to 'from' is never read.
And memcpy_from_folio() only copy the last chunk memory from folio to
destination.
Using 'to += chunk' to replace 'from += chunk' to fix this typo problem.

Fixes: b23d03ef7af5 ("highmem: add memcpy_to_folio() and memcpy_from_folio()")
Signed-off-by: Su Hui <suhui@nfschina.com>
---
 include/linux/highmem.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Matthew Wilcox Nov. 30, 2023, 4:15 a.m. UTC | #1
On Thu, Nov 30, 2023 at 11:40:18AM +0800, Su Hui wrote:
> Clang static checker complains that value stored to 'from' is never read.
> And memcpy_from_folio() only copy the last chunk memory from folio to
> destination.
> Using 'to += chunk' to replace 'from += chunk' to fix this typo problem.
> 
> Fixes: b23d03ef7af5 ("highmem: add memcpy_to_folio() and memcpy_from_folio()")
> Signed-off-by: Su Hui <suhui@nfschina.com>

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
  

Patch

diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index 4cacc0e43b51..be20cff4ba73 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -454,7 +454,7 @@  static inline void memcpy_from_folio(char *to, struct folio *folio,
 		memcpy(to, from, chunk);
 		kunmap_local(from);
 
-		from += chunk;
+		to += chunk;
 		offset += chunk;
 		len -= chunk;
 	} while (len > 0);