[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230608013454.15813-1-stephen@networkplumber.org>
Date: Wed, 7 Jun 2023 18:34:54 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: netdev@...r.kernel.org
Cc: Stephen Hemminger <stephen@...workplumber.org>
Subject: [PATCH iproute2] rt_names: check for malloc() failure
Fixes issue reported by Gcc 13 analayzer.
Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
lib/rt_names.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/rt_names.c b/lib/rt_names.c
index b441e98f8078..68db74e301ff 100644
--- a/lib/rt_names.c
+++ b/lib/rt_names.c
@@ -81,6 +81,10 @@ rtnl_hash_initialize(const char *file, struct rtnl_hash_entry **hash, int size)
continue;
entry = malloc(sizeof(*entry));
+ if (entry == NULL) {
+ fprintf(stderr, "malloc error: for entry\n");
+ break;
+ }
entry->id = id;
entry->name = strdup(namebuf);
entry->next = hash[id & (size - 1)];
--
2.39.2
Powered by blists - more mailing lists