Skip to contentSkip to conversation

remoteproc: off by one in rproc_virtio_new_vringh()

PATCH New Dan Carpenter 1 participant 1 message Feb 22, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remoteproc: off by one in rproc_virtio_new_vringh()

It should be >= ARRAY_SIZE() instead of > ARRAY_SIZE() because it is an index.

drivers/remoteproc/remoteproc_virtio.c +1 -1
index dba33ff..b5e3af5 100644
@@ -208,7 +208,7 @@ rproc_virtio_new_vringh(struct virtio_device *vdev, unsigned index,
 	struct vringh *vrh;
 	int err;
 
-	if (index > ARRAY_SIZE(rvdev->vring)) {
+	if (index >= ARRAY_SIZE(rvdev->vring)) {
 		dev_err(&rvdev->vdev.dev, "bad vring index: %d\n", index);
 		return NULL;
 	}