Fix for the below issues - 1. valgrind reports memory leaks in export_free_gpios. 'line' pointer was never freed.
==5732== 120 bytes in 1 blocks are definitely lost in loss record 130 of 271 ==5732== at 0x482CBB8: malloc (vg_replace_malloc.c:270) ==5732== by 0x48CC633: getdelim (iogetdelim.c:67) ==5732== by 0xB303: export_free_gpios (stdio.h:117) ==5732== by 0xB3DD: gpio_init (gpio.c:376) ==5732== by 0x97F5: main (powerdebug.c:264) 2. Open files need to be closed. diff --git a/gpio.c b/gpio.c index 39480b0..076b260 100644 --- a/gpio.c +++ b/gpio.c @@ -353,7 +353,15 @@ void export_free_gpios(void) if (system(command) < 0) printf("error: failed to export gpio-%d\n", i); } + + free(line); out: + if(fgpio) + fclose(fgpio); + + if(fgpio_export) + fclose(fgpio_export); + return; } -- Thanks, -Meraj _______________________________________________ linaro-dev mailing list linaro-dev@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-dev