From f996293855ac294635883d81b3d55f13ab1f5170 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Tue, 24 Sep 2024 21:30:13 +0200 Subject: [PATCH] libkmod: Plug memory leak on error path Fix memory leak on error path introduced with read_u32 error checks. Signed-off-by: Tobias Stoeckmann Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/153 Signed-off-by: Lucas De Marchi --- libkmod/libkmod-index.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libkmod/libkmod-index.c b/libkmod/libkmod-index.c index 949a7839..154cc43b 100644 --- a/libkmod/libkmod-index.c +++ b/libkmod/libkmod-index.c @@ -338,8 +338,10 @@ struct index_file *index_file_open(const char *filename) goto err; new->file = file; - if (read_u32(new->file, &new->root_offset) < 0) + if (read_u32(new->file, &new->root_offset) < 0) { + free(new); goto err; + } errno = 0; return new;