beaglelogic: Fix resource leak

This commit is contained in:
Florian Ragwitz 2020-11-28 18:18:35 -08:00 committed by Soeren Apel
parent fe185e4990
commit a99ff45359
1 changed files with 4 additions and 2 deletions

View File

@ -88,10 +88,12 @@ static int beaglelogic_get_lasterror(struct dev_context *devc)
if ((fd = open(BEAGLELOGIC_SYSFS_ATTR(lasterror), O_RDONLY)) == -1)
return SR_ERR;
if ((ret = read(fd, buf, 16)) < 0)
ret = read(fd, buf, 16);
close(fd);
if (ret)
return SR_ERR;
close(fd);
devc->last_error = strtoul(buf, NULL, 10);
return SR_OK;