Skip to content
This repository was archived by the owner on Feb 26, 2020. It is now read-only.

Commit 98629a1

Browse files
Ludovic Rousseaualan-softiron-limited
authored andcommitted
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.
1 parent b5b2e17 commit 98629a1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

linux/hid.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ static int get_device_string(hid_device *dev, enum device_string_id key, wchar_t
274274
}
275275

276276
/* Get the dev_t (major/minor numbers) from the file handle. */
277-
fstat(dev->device_handle, &s);
277+
ret = fstat(dev->device_handle, &s);
278+
if (-1 == ret)
279+
return ret;
278280
/* Open a udev device from the dev_t. 'c' means character device. */
279281
udev_dev = udev_device_new_from_devnum(udev, 'c', s.st_rdev);
280282
if (udev_dev) {

0 commit comments

Comments
 (0)