crypto: hash - Use nth_page instead of doing it by hand
authorHerbert Xu <herbert@gondor.apana.org.au>
Fri, 14 Mar 2025 03:27:23 +0000 (11:27 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 21 Mar 2025 09:33:39 +0000 (17:33 +0800)
Use nth_page instead of adding n to the page pointer.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/ahash.c

index 1fe5948802957a5a34f493732ca55e03812d784b..06559e5a715bbb5b2abf92e5665e1eb94258f417 100644 (file)
@@ -80,7 +80,7 @@ static int hash_walk_new_entry(struct crypto_hash_walk *walk)
 
        sg = walk->sg;
        walk->offset = sg->offset;
-       walk->pg = sg_page(walk->sg) + (walk->offset >> PAGE_SHIFT);
+       walk->pg = nth_page(sg_page(walk->sg), (walk->offset >> PAGE_SHIFT));
        walk->offset = offset_in_page(walk->offset);
        walk->entrylen = sg->length;
 
@@ -221,7 +221,7 @@ int shash_ahash_digest(struct ahash_request *req, struct shash_desc *desc)
        if (!IS_ENABLED(CONFIG_HIGHMEM))
                return crypto_shash_digest(desc, data, nbytes, req->result);
 
-       page += offset >> PAGE_SHIFT;
+       page = nth_page(page, offset >> PAGE_SHIFT);
        offset = offset_in_page(offset);
 
        if (nbytes > (unsigned int)PAGE_SIZE - offset)