From 7bdaa8dbb5e71f3ee6c3346d1b0134868b07bfa4 Mon Sep 17 00:00:00 2001 From: HiGarfield <32226909+HiGarfield@users.noreply.github.com> Date: Sun, 8 Oct 2023 17:57:52 +0800 Subject: [PATCH] fix a memory leak Signed-off-by: HiGarfield <32226909+HiGarfield@users.noreply.github.com> --- tools/eeprom.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/eeprom.c b/tools/eeprom.c index 399058ed7..ea9b90710 100644 --- a/tools/eeprom.c +++ b/tools/eeprom.c @@ -222,8 +222,10 @@ mt76_eeprom_changes(void) buf = malloc(EEPROM_PART_SIZE); fseek(f, mtd_offset, SEEK_SET); ret = fread(buf, 1, EEPROM_PART_SIZE, f); - if (ret != EEPROM_PART_SIZE) + if (ret != EEPROM_PART_SIZE) { + free(buf); return EXIT_FAILURE; + } for (i = 0; i < EEPROM_PART_SIZE; i++) { if (buf[i] == eeprom_data[i]) continue;