[PATCH i-g-t v2 3/5] tests/prime_udl: Fix error handling

Kamil Konieczny
2026-04-22T15:45:19Z

Open function returns -1 on error so error check was never hit.
Fix it and handle it properly.

Signed-off-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
Reviewed-by: Karthik B S <karthik.b.s@intel.com>
---
tests/prime_udl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/prime_udl.c b/tests/prime_udl.c
index b1524e6de..5d2c952d5 100644
--- a/tests/prime_udl.c
+++ b/tests/prime_udl.c
@@ -47,11 +47,11 @@ static int find_and_open_devices(void)
sprintf(path, "/dev/dri/card%d", i);
if (venid == 0x8086 && intel_fd == -1) {
intel_fd = open(path, O_RDWR);
- if (!intel_fd)
+ if (intel_fd == -1)
return -1;
} else if (venid == 0x17e9 && udl_fd == -1) {
udl_fd = open(path, O_RDWR);
- if (!udl_fd)
+ if (udl_fd == -1)
return -1;
}
}
--
2.54.0