]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
kselftests: dmabuf-heaps: Ensure the driver name is null-terminated
authorZenghui Yu <yuzenghui@huawei.com>
Mon, 29 Jul 2024 02:46:04 +0000 (10:46 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Sep 2024 09:11:38 +0000 (11:11 +0200)
commitd43fde5ebfe7ea1b8189c67dcf37ceb5371158b8
treeac7037a2b45a53cb3693145da174848be6c3ab54
parent5a022269abb22809f2a174b90f200fc4b9526058
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 <yuzenghui@huawei.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20240729024604.2046-1-yuzenghui@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c