This defect was found by the coccinelle script "unchecked-strdup.cocci".
It can be backported to all supported branches.
(cherry picked from commit
abee5468509a77537015a7e5dc37268d4d564e03)
Signed-off-by: Willy Tarreau <w@1wt.eu>
entry = calloc(1, sizeof(*entry));
if (!entry)
- goto out;
+ goto err_close_fd;
entry->fd = fd;
entry->node.key = strdup(ns_name);
+ if (!entry->node.key)
+ goto err_free_entry;
+
entry->name_len = strlen(ns_name);
ebis_insert(&namespace_tree_root, &entry->node);
out:
return entry;
+
+/* free all allocated stuff and return entry */
+err_free_entry:
+ ha_free(&entry);
+err_close_fd:
+ close(fd);
+ return entry;
}
const struct netns_entry* netns_store_lookup(const char *ns_name, size_t ns_name_len)