From: Florian Ragwitz Date: Sun, 29 Nov 2020 02:18:35 +0000 (-0800) Subject: beaglelogic: Fix resource leak X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a99ff45359a590739c8a66458511c64d00033a5d;p=libsigrok.git beaglelogic: Fix resource leak --- diff --git a/src/hardware/beaglelogic/beaglelogic_native.c b/src/hardware/beaglelogic/beaglelogic_native.c index 42d51edf..af5e650f 100644 --- a/src/hardware/beaglelogic/beaglelogic_native.c +++ b/src/hardware/beaglelogic/beaglelogic_native.c @@ -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;