caif_virtio: fix wrong pointer check in cfv_probe()
Subsystems (2)
PATCH 1/1 caif_virtio: fix wrong pointer check in cfv_probe()
del_vqs() frees virtqueues, therefore cfv->vq_tx pointer should be checked for NULL before calling it, not cfv->vdev. Also the current implementation is redundant because the pointer cfv->vdev is dereferenced before it is checked for NULL.
Fix this by checking cfv->vq_tx for NULL instead of cfv->vdev before calling del_vqs().
Found by Linux Verification Center (linuxtesting.org) with Svace.
--- drivers/net/caif/caif_virtio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/caif/caif_virtio.c +1 -1
@@ -745,7 +745,7 @@ static int cfv_probe(struct virtio_device *vdev)if (cfv->vr_rx) vdev->vringh_config->del_vrhs (cfv->vdev); -if (cfv->vdev) +if (cfv->vq_tx) vdev->config->del_vqs (cfv->vdev);free_netdev (netdev);return err;
Signature · 1 line
2.48.1
Quoted 21 lines · Vitaliy Shevtsov
del_vqs()frees virtqueues, thereforecfv->vq_txpointer should be checked for NULL before calling it, notcfv->vdev. Also the current implementation is redundant because the pointercfv->vdevis dereferenced before it is checked for NULL.Fix this by checking
cfv->vq_txfor NULL instead ofcfv->vdevbefore callingdel_vqs().Found by Linux Verification Center (linuxtesting.org) with Svace.
Fixes 0d2e1a2926b1 ("caif_virtio: Introduce caif over virtio")Signed-off-by Vitaliy Shevtsov <[email protected]>--- drivers/net/caif/caif_virtio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/caif/caif_virtio.c +0
-0
drivers/net/caif/caif_virtio.c static int cfv_probe(struct virtio_device *vdev) · line 751
Quoted 8 lines
drivers/net/caif/caif_virtio.c +1
-1@@ -745,7 +745,7 @@ static int cfv_probe(struct virtio_device *vdev)if (cfv->vr_rx) vdev->vringh_config->del_vrhs (cfv->vdev); -if (cfv->vdev) +if (cfv->vq_tx) vdev->config->del_vqs (cfv->vdev);free_netdev (netdev);return err;
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Thu, 27 Feb 2025 23:46:27 +0500 you wrote:
del_vqs()frees virtqueues, thereforecfv->vq_txpointer should be checked for NULL before calling it, notcfv->vdev. Also the current implementation is redundant because the pointercfv->vdevis dereferenced before it is checked for NULL.Fix this by checking
cfv->vq_txfor NULL instead ofcfv->vdevbefore callingdel_vqs().[...]
Here is the summary with links:
- caif_virtio: fix wrong pointer check in cfv_probe()
https://git.kernel.org/netdev/net/c/a466fd7e9faf
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html