diff --git a/projects/rocr-runtime/src/libhsakmt.c b/projects/rocr-runtime/src/libhsakmt.c index a9e250d087..b742e799c6 100644 --- a/projects/rocr-runtime/src/libhsakmt.c +++ b/projects/rocr-runtime/src/libhsakmt.c @@ -13,7 +13,7 @@ int kmtIoctl(int fd, unsigned long request, void *arg) ret = ioctl(fd, request, arg); } while (ret == -1 && (errno == EINTR || errno == EAGAIN)); - if (errno == EBADF) { + if (ret == -1 && errno == EBADF) { /* In case pthread_atfork didn't catch it, this will * make any subsequent hsaKmt calls fail in CHECK_KFD_OPEN. */