]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
tools/virtio: check mmap return value in vringh_test
authorlonglong yan <yanlonglong@kylinos.cn>
Fri, 5 Jun 2026 02:14:45 +0000 (10:14 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 10 Jun 2026 06:16:59 +0000 (02:16 -0400)
commitec6177dfe98b9be1c3ede6c0dfe4394ea2a76959
tree774aac3654a8cc7c864a2646fd212dfbc5d0af62
parent8f6898fe80794f2d7c3d38c1158c806e4074a1c4
tools/virtio: check mmap return value in vringh_test

In parallel_test(), the return values of mmap() for both host_map and
guest_map are not checked against MAP_FAILED. If mmap() fails, the
subsequent code will dereference the invalid pointer, leading to a
segmentation fault.

Add MAP_FAILED checks after both mmap() calls, using err() to report
the error and exit, consistent with the existing error handling style
in this file (e.g., the open() call on line 149).

Fixes: 1515c5ce26ae ("tools/virtio: add vring_test.")
Signed-off-by: longlong yan <yanlonglong@kylinos.cn>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-ID: <20260605021446.1611-1-yanlonglong@kylinos.cn>
tools/virtio/vringh_test.c