From: Sami Uddin <sami.md...@gmail.com> Prevent usage of shared memory regions where the length is zero, as such configurations are not valid and may lead to unexpected behavior.
Signed-off-by: Sami Uddin <sami.md...@gmail.com> --- v3: - Use idiomatic 'if (!region->len)' as suggested by reviewer v2: - Fixed coding style issue: added space after 'if' statement include/linux/virtio_config.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h index 169c7d367fac..b3e1d30c765b 100644 --- a/include/linux/virtio_config.h +++ b/include/linux/virtio_config.h @@ -329,6 +329,8 @@ static inline bool virtio_get_shm_region(struct virtio_device *vdev, struct virtio_shm_region *region, u8 id) { + if (!region->len) + return false; if (!vdev->config->get_shm_region) return false; return vdev->config->get_shm_region(vdev, region, id); -- 2.34.1