Skip to contentSkip to conversation

virtio: fix off by one device id comparison

PATCH New Vincent Stehlé 3 participants 3 messages Feb 14, 2021 – Feb 25, 2021 virtio core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio: fix off by one device id comparison

VIRTIO_ID_MAX_NUM is the largest device ID plus 1. Therefore a device id cannot be greater or equal to VIRTIO_ID_MAX_NUM. Fix the comparison accordingly.

Fixes 8fb49b4c7a82 ("dm: Add a new uclass driver for VirtIO transport devices")
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
---
 drivers/virtio/virtio-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virtio/virtio-uclass.c +1 -1
index cf2cfaef2cf..0379536c542 100644
@@ -227,7 +227,7 @@ static int virtio_uclass_post_probe(struct udevice *udev)
 	struct udevice *vdev;
 	int ret;
 
-	if (uc_priv->device > VIRTIO_ID_MAX_NUM) {
+	if (uc_priv->device >= VIRTIO_ID_MAX_NUM) {
 		debug("(%s): virtio device ID %d exceeds maximum num\n",
 		      udev->name, uc_priv->device);
 		return 0;
Signature · 1 line
2.29.2
#1 lore raw

PATCH 1/1 virtio: fix off by one device id comparison

Quoted 5 lines · Vincent Stehl?

VIRTIO_ID_MAX_NUM is the largest device ID plus 1. Therefore a device id cannot be greater or equal to VIRTIO_ID_MAX_NUM. Fix the comparison accordingly.

Quoted 8 lines
Fixes 8fb49b4c7a82 ("dm: Add a new uclass driver for VirtIO transport devices")
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>
---
 drivers/virtio/virtio-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#2 lore raw

PATCH 1/1 virtio: fix off by one device id comparison

In reply to Vincent Stehlé
Quoted 8 lines · Vincent Stehl?

VIRTIO_ID_MAX_NUM is the largest device ID plus 1. Therefore a device id cannot be greater or equal to VIRTIO_ID_MAX_NUM. Fix the comparison accordingly.

Fixes 8fb49b4c7a82 ("dm: Add a new uclass driver for VirtIO transport devices")
Cc Simon Glass <[email protected]>
Cc Bin Meng <[email protected]>

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210225/6e04cd27/attachment.sig>