From 9a53880b9b59f4afa29e8111bf6c21783de6f426 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 11 Nov 2023 13:34:21 +1100 Subject: [PATCH] [common] ivshmem: fix failure to check ioctl for error result --- common/src/platform/linux/ivshmem.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/common/src/platform/linux/ivshmem.c b/common/src/platform/linux/ivshmem.c index ae152e82..2ffd536d 100644 --- a/common/src/platform/linux/ivshmem.c +++ b/common/src/platform/linux/ivshmem.c @@ -119,7 +119,7 @@ bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDevice) { DEBUG_ASSERT(dev); - unsigned int devSize; + int devSize; int devFd; bool hasDMA; @@ -139,6 +139,12 @@ bool ivshmemOpenDev(struct IVSHMEM * dev, const char * shmDevice) // get the device size devSize = ioctl(devFd, KVMFR_DMABUF_GETSIZE, 0); + if (devSize < 0) + { + DEBUG_ERROR("Failed to get the device size"); + close(devFd); + return false; + } hasDMA = true; } else