Revert "vhost/scsi: null-ptr-dereference in vhost_scsi_get_req()"

This reverts commit 11889a0690.
This commit is contained in:
Ksawlii 2024-11-24 00:23:00 +01:00
parent a64018a67a
commit f8bd4809aa

View file

@ -919,23 +919,20 @@ vhost_scsi_get_req(struct vhost_virtqueue *vq, struct vhost_scsi_ctx *vc,
/* virtio-scsi spec requires byte 0 of the lun to be 1 */
vq_err(vq, "Illegal virtio-scsi lun: %u\n", *vc->lunp);
} else {
struct vhost_scsi_tpg **vs_tpg, *tpg = NULL;
struct vhost_scsi_tpg **vs_tpg, *tpg;
if (vc->target) {
/* validated at handler entry */
vs_tpg = vhost_vq_get_backend(vq);
tpg = READ_ONCE(vs_tpg[*vc->target]);
if (unlikely(!tpg)) {
vq_err(vq, "Target 0x%x does not exist\n", *vc->target);
goto out;
}
vs_tpg = vhost_vq_get_backend(vq); /* validated at handler entry */
tpg = READ_ONCE(vs_tpg[*vc->target]);
if (unlikely(!tpg)) {
vq_err(vq, "Target 0x%x does not exist\n", *vc->target);
} else {
if (tpgp)
*tpgp = tpg;
ret = 0;
}
if (tpgp)
*tpgp = tpg;
ret = 0;
}
out:
return ret;
}