[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20241113105219.29134-1-kirjanov@gmail.com>
Date: Wed, 13 Nov 2024 13:52:19 +0300
From: Denis Kirjanov <kirjanov@...il.com>
To: stephen@...workplumber.org,
dsahern@...nel.org
Cc: netdev@...r.kernel.org,
Denis Kirjanov <kirjanov@...il.com>
Subject: [iproute] lib: names: check calloc return value in db_names_alloc
db_names_load() may crash since it touches the
hash member. Fix it by checking the return value
Signed-off-by: Denis Kirjanov <kirjanov@...il.com>
---
lib/names.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/names.c b/lib/names.c
index cbfa971f..4ecae92b 100644
--- a/lib/names.c
+++ b/lib/names.c
@@ -55,6 +55,10 @@ struct db_names *db_names_alloc(void)
db->size = MAX_ENTRIES;
db->hash = calloc(db->size, sizeof(struct db_entry *));
+ if (!db->hash) {
+ free(db);
+ return NULL;
+ }
return db;
}
--
2.43.0
Powered by blists - more mailing lists