From a2dd9a5f1c24f17f59eba29ad0bae2f704bbe55b Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Wed, 8 Oct 2025 00:16:51 +0200 Subject: [PATCH] Fix leak on error in the new devup --- cmdline/unix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmdline/unix.c b/cmdline/unix.c index 7841fa71..6add6ddb 100644 --- a/cmdline/unix.c +++ b/cmdline/unix.c @@ -1379,6 +1379,7 @@ static int devup(dev_t device) f = open(file, O_RDONLY | O_DIRECT); if (f < 0) { /* LCOV_EXCL_START */ + free(buf); log_fatal("Failed to open device '%u:%u'.\n", major(device), minor(device)); return -1; /* LCOV_EXCL_STOP */ @@ -1388,6 +1389,7 @@ static int devup(dev_t device) if (ret < 0) { /* LCOV_EXCL_START */ close(f); + free(buf); log_fatal("Failed to read device '%u:%u'.\n", major(device), minor(device)); return -1; /* LCOV_EXCL_STOP */ @@ -1396,6 +1398,7 @@ static int devup(dev_t device) ret = close(f); if (ret < 0) { /* LCOV_EXCL_START */ + free(buf); log_fatal("Failed to close device '%u:%u'.\n", major(device), minor(device)); return -1; /* LCOV_EXCL_STOP */