From ecc2c92027dbd1cf0f1797e571bc50762aa4a690 Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Tue, 6 May 2014 18:12:53 +0100 Subject: [PATCH] gpio: only call ferror in free() case as dev has already been free'd by swig code Signed-off-by: Brendan Le Foll --- src/gpio/gpio.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/gpio/gpio.c b/src/gpio/gpio.c index d1ec080..e49213a 100644 --- a/src/gpio/gpio.c +++ b/src/gpio/gpio.c @@ -211,15 +211,16 @@ maa_gpio_unexport(maa_gpio_context *dev) fwrite(bu, sizeof(char), length, unexport_f); fclose(unexport_f); - if (ferror(dev->value_fp) != 0) { - return MAA_ERROR_INVALID_RESOURCE; - } return MAA_SUCCESS; } maa_result_t maa_gpio_close(maa_gpio_context *dev) { + if (ferror(dev->value_fp) != 0) { + return MAA_ERROR_INVALID_RESOURCE; + } + maa_gpio_unexport(dev); free(dev); return MAA_SUCCESS;