hwrng: virtio - use min() in copy_data()

Use the simpler min() macro since all values are unsigned and
compatible. The subtraction avail - vi->data_idx is also guaranteed to
be positive by the preceding check.

Signed-off-by: Thorsten Blum <blum@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Thorsten Blum 2026-09-26 07:58:54 +02:00 committed by Herbert Xu
parent b5c2df4297
commit 468dd85acf

View File

@ -81,13 +81,13 @@ static unsigned int copy_data(struct virtrng_info *vi, void *buf,
* steered into adjacent slab memory, including under
* speculation.
*/
avail = min_t(unsigned int, vi->data_avail, sizeof(vi->data));
avail = min(vi->data_avail, sizeof(vi->data));
if (vi->data_idx >= avail) {
vi->data_avail = 0;
request_entropy(vi);
return 0;
}
size = min_t(unsigned int, size, avail - vi->data_idx);
size = min(size, avail - vi->data_idx);
idx = array_index_nospec(vi->data_idx, sizeof(vi->data));
memcpy(buf, vi->data + idx, size);
vi->data_idx += size;