linux-next: manual merge of the crypto tree with the origin tree
From: Mark Brown
Date: Mon Nov 16 2026 - 11:43:59 EST
Hi all,
Today's linux-next merge of the crypto tree got a conflict in:
drivers/char/hw_random/virtio-rng.c
between commit:
0f7bf47f5a0cc ("hwrng: virtio - prevent use-after-free after a failed restore")
from the origin tree and commits:
a3eaee98eecc4 ("hwrng: virtio - prevent use-after-free after a failed restore")
277b0dae660c3 ("hwrng: virtio - simplify probe_common()")
from the crypto tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
diff --combined drivers/char/hw_random/virtio-rng.c
index 45d87c0614a5e,892720b1ac6f9..0000000000000
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@@ -70,7 -70,7 +70,7 @@@ static void request_entropy(struct virt
static unsigned int copy_data(struct virtrng_info *vi, void *buf,
unsigned int size)
{
- unsigned int idx, avail;
+ unsigned int idx;
/*
* vi->data_avail was set from the device-reported used.len and
@@@ -81,13 -81,13 +81,13 @@@
* steered into adjacent slab memory, including under
* speculation.
*/
- avail = min(vi->data_avail, sizeof(vi->data));
- if (vi->data_idx >= avail) {
+ if (vi->data_idx >= sizeof(vi->data)) {
vi->data_avail = 0;
request_entropy(vi);
return 0;
}
- size = min(size, avail - vi->data_idx);
+ vi->data_avail = min(vi->data_avail, sizeof(vi->data) - vi->data_idx);
+ size = min(size, vi->data_avail);
idx = array_index_nospec(vi->data_idx, sizeof(vi->data));
memcpy(buf, vi->data + idx, size);
vi->data_idx += size;
@@@ -150,17 -150,17 +150,17 @@@ static void virtio_cleanup(struct hwrn
static int probe_common(struct virtio_device *vdev)
{
- int err, index;
- struct virtrng_info *vi = NULL;
+ int err;
+ struct virtrng_info *vi;
vi = kzalloc_obj(struct virtrng_info);
if (!vi)
return -ENOMEM;
- vi->index = index = ida_alloc(&rng_index_ida, GFP_KERNEL);
- if (index < 0) {
- err = index;
- goto err_ida;
+ vi->index = ida_alloc(&rng_index_ida, GFP_KERNEL);
+ if (vi->index < 0) {
+ err = vi->index;
+ goto err;
}
snprintf(vi->name, sizeof(vi->name), "virtio_rng.%d", vi->index);
init_completion(&vi->have_data);
@@@ -177,7 -177,8 +177,8 @@@
vi->vq = virtio_find_single_vq(vdev, random_recv_done, "input");
if (IS_ERR(vi->vq)) {
err = PTR_ERR(vi->vq);
- goto err_find;
+ ida_free(&rng_index_ida, vi->index);
+ goto err;
}
virtio_device_ready(vdev);
@@@ -187,9 -188,7 +188,7 @@@
return 0;
- err_find:
- ida_free(&rng_index_ida, index);
- err_ida:
+ err:
vdev->priv = NULL;
kfree(vi);
return err;
@@@ -245,26 -244,27 +244,27 @@@ static int virtrng_freeze(struct virtio
static int virtrng_restore(struct virtio_device *vdev)
{
+ struct virtrng_info *vi;
int err;
err = probe_common(vdev);
- if (!err) {
- struct virtrng_info *vi = vdev->priv;
+ if (err)
+ return err;
+ vi = vdev->priv;
- /*
- * Set hwrng_removed to ensure that virtio_read()
- * does not block waiting for data before the
- * registration is complete.
- */
- vi->hwrng_removed = true;
- err = hwrng_register(&vi->hwrng);
- if (!err) {
- vi->hwrng_register_done = true;
- vi->hwrng_removed = false;
- }
- }
+ /*
+ * Set hwrng_removed to ensure that virtio_read()
+ * does not block waiting for data before the
+ * registration is complete.
+ */
+ vi->hwrng_removed = true;
+ err = hwrng_register(&vi->hwrng);
+ if (err)
+ return err;
- return err;
+ vi->hwrng_register_done = true;
+ vi->hwrng_removed = false;
+ return 0;
}
static const struct virtio_device_id id_table[] = {
Attachment:
signature.asc
Description: PGP signature