Message ID | 9a2f66123f74e8c452b0fa61cb5da6e0c2804070.1640004743.git.renzhen.rz@alibaba-inc.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | virtio_mem: fix panic on mb_states indexing overflow | expand |
diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c index 96e5a8782769..e403e6d95c0b 100644 --- a/drivers/virtio/virtio_mem.c +++ b/drivers/virtio/virtio_mem.c @@ -486,7 +486,9 @@ static int virtio_mem_sbm_mb_states_prepare_next_mb(struct virtio_mem *vm) #define virtio_mem_sbm_for_each_mb_rev(_vm, _mb_id, _state) \ for (_mb_id = _vm->sbm.next_mb_id - 1; \ - _mb_id >= _vm->sbm.first_mb_id && _vm->sbm.mb_count[_state]; \ + _mb_id >= _vm->sbm.first_mb_id && \ + _mb_id < vm->sbm.next_mb_id && \ + _vm->sbm.mb_count[_state]; \ _mb_id--) \ if (virtio_mem_sbm_get_mb_state(_vm, _mb_id) == _state)