Skip to content

Commit

Permalink
linux: Check value returned by fstat(2)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Ludovic Rousseau authored and alan-softiron-limited committed Mar 3, 2016
1 parent b5b2e17 commit 98629a1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion linux/hid.c
Expand Up @@ -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) {
Expand Down

0 comments on commit 98629a1

Please sign in to comment.