Skip to content

Commit d43fde5

Browse files
Zenghui Yugregkh
Zenghui Yu
authored andcommitted
kselftests: dmabuf-heaps: Ensure the driver name is null-terminated
[ Upstream commit 291e4baf70019f17a81b7b47aeb186b27d222159 ] Even if a vgem device is configured in, we will skip the import_vgem_fd() test almost every time. TAP version 13 1..11 # Testing heap: system # ======================================= # Testing allocation and importing: ok 1 # SKIP Could not open vgem -1 The problem is that we use the DRM_IOCTL_VERSION ioctl to query the driver version information but leave the name field a non-null-terminated string. Terminate it properly to actually test against the vgem device. While at it, let's check the length of the driver name is exactly 4 bytes and return early otherwise (in case there is a name like "vgemfoo" that gets converted to "vgem\0" unexpectedly). Signed-off-by: Zenghui Yu <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent 5a02226 commit d43fde5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ static int check_vgem(int fd)
2828
version.name = name;
2929

3030
ret = ioctl(fd, DRM_IOCTL_VERSION, &version);
31-
if (ret)
31+
if (ret || version.name_len != 4)
3232
return 0;
3333

34+
name[4] = '\0';
35+
3436
return !strcmp(name, "vgem");
3537
}
3638

0 commit comments

Comments
 (0)