mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
platform/mellanox: fix potential race in mlxbf-tmfifo driver
This commit adds memory barrier for the 'vq' update in function mlxbf_tmfifo_virtio_find_vqs() to avoid potential race due to out-of-order memory write. It also adds barrier for the 'is_ready' flag to make sure the initializations are visible before this flag is checked. Signed-off-by: Liming Sun <limings@nvidia.com> Reviewed-by: Vadim Pasternak <vadimp@nvidia.com> Link: https://lore.kernel.org/r/b98c0ab61d644ba38fa9b3fd1607b138b0dd820b.1682518748.git.limings@nvidia.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
committed by
Hans de Goede
parent
4b65f95c87
commit
3d43f9f639
@@ -784,7 +784,7 @@ static void mlxbf_tmfifo_rxtx(struct mlxbf_tmfifo_vring *vring, bool is_rx)
|
|||||||
fifo = vring->fifo;
|
fifo = vring->fifo;
|
||||||
|
|
||||||
/* Return if vdev is not ready. */
|
/* Return if vdev is not ready. */
|
||||||
if (!fifo->vdev[devid])
|
if (!fifo || !fifo->vdev[devid])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Return if another vring is running. */
|
/* Return if another vring is running. */
|
||||||
@@ -980,9 +980,13 @@ static int mlxbf_tmfifo_virtio_find_vqs(struct virtio_device *vdev,
|
|||||||
|
|
||||||
vq->num_max = vring->num;
|
vq->num_max = vring->num;
|
||||||
|
|
||||||
|
vq->priv = vring;
|
||||||
|
|
||||||
|
/* Make vq update visible before using it. */
|
||||||
|
virtio_mb(false);
|
||||||
|
|
||||||
vqs[i] = vq;
|
vqs[i] = vq;
|
||||||
vring->vq = vq;
|
vring->vq = vq;
|
||||||
vq->priv = vring;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1302,6 +1306,9 @@ static int mlxbf_tmfifo_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
mod_timer(&fifo->timer, jiffies + MLXBF_TMFIFO_TIMER_INTERVAL);
|
mod_timer(&fifo->timer, jiffies + MLXBF_TMFIFO_TIMER_INTERVAL);
|
||||||
|
|
||||||
|
/* Make all updates visible before setting the 'is_ready' flag. */
|
||||||
|
virtio_mb(false);
|
||||||
|
|
||||||
fifo->is_ready = true;
|
fifo->is_ready = true;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user