Skip to contentSkip to conversation

rt_names: check for malloc() failure

PATCH Applied Stephen Hemminger 2 participants 2 messages Jun 8, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rt_names: check for malloc() failure

Fixes issue reported by Gcc 13 analayzer.

---
 lib/rt_names.c | 4 ++++
 1 file changed, 4 insertions(+)
lib/rt_names.c +4 -0
index b441e98f8078..68db74e301ff 100644
@@ -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)];
Signature · 1 line
2.39.2
#1 lore raw
This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:

Hello:

This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:

Quoted 6 lines · On Wed, 7 Jun 2023 18:34:54 -0700 you wrote:

Fixes issue reported by Gcc 13 analayzer.

---
 lib/rt_names.c | 4 ++++
 1 file changed, 4 insertions(+)

Here is the summary with links:
- [iproute2] rt_names: check for malloc() failure

    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=507fe042181c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html