dma-buf: heaps: bugfix for selftest failure
Subsystems (3)
PATCH 1/1 dma-buf: heaps: bugfix for selftest failure
If the 'name' array in check_vgem() was not initialized to null, the value of name[4] may be random. Which will cause strcmp(name, "vgem") failed.
--- tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c +1 -1
@@ -22,7 +22,7 @@static int check_vgem (int fd) {drm_version_t version = {0 }; -char name[5 ]; +char name[5 ] = {0 };int ret; version.name_len =4 ;
Signature · 1 line
2.7.4
shuah
maintainerQuoted 3 lines · Leon He
If the 'name' array in
check_vgem()was not initialized to null, the value of name[4] may be random. Which will causestrcmp(name, "vgem")failed.
Nit: "to fail" instead of "failed"
Quoted 12 lines
Signed-off-by Leon He <[email protected]>--- tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c +0
-0
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c line 28
Quoted 8 lines
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c +1
-1@@ -22,7 +22,7 @@static int check_vgem (int fd) {drm_version_t version = {0 }; -char name[5 ]; +char name[5 ] = {0 };int ret; version.name_len =4 ;
return !strcmp(name, "vgem");
While you are at it, why not change strcmp() to strncmp()?
thanks,
-- Shuah
Quoted 7 lines · Leon He
Quoted 3 lines
If the 'name' array in
check_vgem()was not initialized to null, the value of name[4] may be random. Which will causestrcmp(name, "vgem")failed.Nit: "to fail" instead of "failed"
OK, thanks!
Quoted 20 lines
Quoted 20 lines
Signed-off-by Leon He <[email protected]>--- tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c +1
-1@@ -22,7 +22,7 @@static int check_vgem (int fd) {drm_version_t version = {0 }; -char name[5 ]; +char name[5 ] = {0 };int ret;
Quoted 7 lines
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c line 28
Quoted 2 lines
tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c +0
-0version.name_len =4 ;return !strcmp(name, "vgem");
While you are at it, why not change
strcmp()tostrncmp()?
OK, I'll change it in patch v3.
thanks,
-- Leon