linux: Check value returned by fstat(2)

Problem reported by the Coverity tool

CID 1042532 (#1 of 1): Unchecked return value from library
(CHECKED_RETURN)2. check_return: Calling function
"fstat(dev->device_handle, &s)" without checking return value. This
library function may fail and return an error code.
This commit is contained in:
Ludovic Rousseau 2013-09-22 21:01:27 +02:00 committed by Alan Ott
parent b5b2e1779b
commit 98629a104b

View File

@ -274,7 +274,9 @@ static int get_device_string(hid_device *dev, enum device_string_id key, wchar_t
}
/* Get the dev_t (major/minor numbers) from the file handle. */
fstat(dev->device_handle, &s);
ret = fstat(dev->device_handle, &s);
if (-1 == ret)
return ret;
/* Open a udev device from the dev_t. 'c' means character device. */
udev_dev = udev_device_new_from_devnum(udev, 'c', s.st_rdev);
if (udev_dev) {