From 87395df82a8fb06f6bc2b116605bb282b6360947 Mon Sep 17 00:00:00 2001 From: Mieczyslaw Nalewaj Date: Sat, 14 Dec 2024 10:30:07 +0100 Subject: [PATCH] tools: fix allocation check and missing memory freeing Fixed allocation checking and freeing buffer memory inside mt76_eeprom_changes() function. Signed-off-by: Mieczyslaw Nalewaj --- tools/eeprom.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/eeprom.c b/tools/eeprom.c index 399058ed7..d8fceaa56 100644 --- a/tools/eeprom.c +++ b/tools/eeprom.c @@ -220,10 +220,14 @@ mt76_eeprom_changes(void) } buf = malloc(EEPROM_PART_SIZE); + if (!buf) + return EXIT_FAILURE; 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;