summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util/comm-i2c.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/util/comm-i2c.c b/util/comm-i2c.c
index bc2684f3da..ea2ca7c94e 100644
--- a/util/comm-i2c.c
+++ b/util/comm-i2c.c
@@ -174,11 +174,11 @@ int comm_init_i2c(void)
{
char *file_path;
char buffer[64];
- FILE *f;
int i;
/* find the device number based on the adapter name */
for (i = 0; i < I2C_MAX_ADAPTER; i++) {
+ FILE *f;
if (asprintf(&file_path, I2C_ADAPTER_NODE,
i, i, EC_I2C_ADDR) < 0)
return -1;
@@ -187,6 +187,7 @@ int comm_init_i2c(void)
if (fgets(buffer, sizeof(buffer), f) &&
!strncmp(buffer, I2C_ADAPTER_NAME, 6)) {
free(file_path);
+ fclose(f);
break;
}
fclose(f);