hwrng: virtio - use snprintf() in probe_common()

While the current code works correctly, replace the unbounded sprintf()
with the safer snprintf() to follow secure coding best practices.

Signed-off-by: Thorsten Blum <blum@kernel.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Thorsten Blum 2026-09-26 07:58:55 +02:00 committed by Herbert Xu
parent 468dd85acf
commit 98807de9ac

View File

@ -162,7 +162,7 @@ static int probe_common(struct virtio_device *vdev)
err = index;
goto err_ida;
}
sprintf(vi->name, "virtio_rng.%d", index);
snprintf(vi->name, sizeof(vi->name), "virtio_rng.%d", vi->index);
init_completion(&vi->have_data);
vi->hwrng = (struct hwrng) {