Message ID | 20241113105349.29327-1-kirjanov@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 225f74761b091e51444cf1f9686547f3c42e44b3 |
Delegated to: | Stephen Hemminger |
Headers | show |
Series | [iproute] lib: names: check calloc return value in db_names_alloc | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Guessing tree name failed - patch did not apply |
Hello: This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <stephen@networkplumber.org>: On Wed, 13 Nov 2024 13:53:49 +0300 you wrote: > db_names_load() may crash since it touches the > hash member. Fix it by checking the return value > > Signed-off-by: Denis Kirjanov <kirjanov@gmail.com> > --- > lib/names.c | 4 ++++ > 1 file changed, 4 insertions(+) Here is the summary with links: - [iproute] lib: names: check calloc return value in db_names_alloc https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=225f74761b09 You are awesome, thank you!
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; }
db_names_load() may crash since it touches the hash member. Fix it by checking the return value Signed-off-by: Denis Kirjanov <kirjanov@gmail.com> --- lib/names.c | 4 ++++ 1 file changed, 4 insertions(+)