Hi Ilya, On Thu, Nov 28, 2024 at 01:07:40AM +0100, Ilya Shipitsin wrote: > This defect was found by the coccinelle script "unchecked-strdup.cocci". > It can be backported to all supported branches. > --- > src/namespace.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/src/namespace.c b/src/namespace.c > index 9cc85a384..12885cd9f 100644 > --- a/src/namespace.c > +++ b/src/namespace.c > @@ -92,6 +92,11 @@ struct netns_entry* netns_store_insert(const char *ns_name) > goto out; > entry->fd = fd; > entry->node.key = strdup(ns_name); > + if (!entry->node.key) { > + free(entry); > + entry = NULL;
Above, you can use ha_free(&entry), which performs both the free() and sets the NULL. We try to use it more so that missing NULLs are easier to spot (i.e. only free() is suspicious and needs longer investigation). Also, the previously created fd will leak, so a close(fd) is missing. Thanks! Willy