nokia-gpio: Fix memory leak
authorBertrand Aygon <bertrand.aygon@intel.com>
Wed, 11 May 2011 15:27:43 +0000 (17:27 +0200)
committerDenis Kenzior <denkenz@gmail.com>
Wed, 11 May 2011 18:29:33 +0000 (13:29 -0500)
All dir opened with opendir must be closed with closedir

plugins/nokia-gpio.c

index b025f3e..57aad8d 100644 (file)
@@ -662,8 +662,10 @@ static int gpio_probe_links(void)
                FILE *nf;
                size_t len;
 
-               if (d == NULL)
+               if (d == NULL) {
+                       (void) closedir(gpio);
                        return 0;
+               }
 
                snprintf(nn, sizeof nn, "%s/%s/name", gpiodir, d->d_name);
 
@@ -700,6 +702,8 @@ static int gpio_probe_links(void)
 
        DBG("%s: %s", "/sys/class/gpio", strerror(errno));
 
+       (void) closedir(gpio);
+
        return -(errno = ENODEV);
 }