]> sigrok.org Git - libsigrok.git/commitdiff
beaglelogic: Fix resource leak
authorFlorian Ragwitz <redacted>
Sun, 29 Nov 2020 02:18:35 +0000 (18:18 -0800)
committerSoeren Apel <redacted>
Sun, 21 Feb 2021 22:05:27 +0000 (23:05 +0100)
src/hardware/beaglelogic/beaglelogic_native.c

index 42d51edf32d858c78bc3c64b8cf25a00818436d4..af5e650f30dbdb89ef034a6d5f96d31e0ae6616c 100644 (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;