]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: stm32 - Remove unnecessary checks before calling memcpy
authorThorsten Blum <thorsten.blum@linux.dev>
Fri, 9 Jan 2026 14:20:36 +0000 (15:20 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 30 Jan 2026 08:09:32 +0000 (16:09 +0800)
memcpy() can be safely called with size 0, which is a no-op. Remove the
unnecessary checks before calling memcpy().

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/stm32/stm32-hash.c

index a4436728b0dba4a2205088d920f2d53ee501f93a..d60147a7594e3bfab3009e791ce0f4c386ec1198 100644 (file)
@@ -1115,8 +1115,7 @@ static int stm32_hash_copy_sgs(struct stm32_hash_request_ctx *rctx,
                return -ENOMEM;
        }
 
-       if (state->bufcnt)
-               memcpy(buf, rctx->hdev->xmit_buf, state->bufcnt);
+       memcpy(buf, rctx->hdev->xmit_buf, state->bufcnt);
 
        scatterwalk_map_and_copy(buf + state->bufcnt, sg, rctx->offset,
                                 min(new_len, rctx->total) - state->bufcnt, 0);
@@ -1300,8 +1299,7 @@ static int stm32_hash_prepare_request(struct ahash_request *req)
        }
 
        /* copy buffer in a temporary one that is used for sg alignment */
-       if (state->bufcnt)
-               memcpy(hdev->xmit_buf, state->buffer, state->bufcnt);
+       memcpy(hdev->xmit_buf, state->buffer, state->bufcnt);
 
        ret = stm32_hash_align_sgs(req->src, nbytes, bs, init, final, rctx);
        if (ret)