libdasd: Check return value for util_file_read_l

The return code of util_file_read_l() isn't checked and therefore
'value' could contain anything in case of an error. Check the return
code and set 'value' to 0 in the error case.

Fixes: https://github.com/ibm-s390-linux/s390-tools/issues/110
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Jan Höppner
2021-03-17 14:16:44 +01:00
parent a65bc51cf4
commit 69526998f0

View File

@@ -218,7 +218,8 @@ int dasd_get_host_access_count(char *device)
return 0;
path = util_path_sysfs("bus/ccw/devices/%s/host_access_count", busid);
util_file_read_l(&value, 10, path);
if (util_file_read_l(&value, 10, path))
value = 0;
free(path);
return value;