ng_socket: plug node reference leak

There is no need to reference node in its constructor, the framework
already granted us a reference.  This extraneous reference was later given
back on socket detach.  However, if node is destroyed before the socket,
the node was leaked.  This leak was harmless until VIMAGE, where
vnet_netgraph_uninit() would cycle through all nodes and shut them down
expecting them to not exist after the shutdown.

Fixes: 1928437497
This commit is contained in:
Gleb Smirnoff committed 2026-06-26 16:35:36 -07:00
1 parent 41bc52c893
commit 4d3cbeb7b4
1 file changed
-2
-2
View File
@@ -506,7 +506,6 @@ ngc_attach(struct socket *so, int type, struct thread *td)
/* Link the node and the private data. */
NG_NODE_SET_PRIVATE(priv->node, priv);
NG_NODE_REF(priv->node);
priv->refs++;
return (0);
@@ -602,7 +601,6 @@ ng_socket_free_priv(struct ngsock *priv)
priv->node = NULL;
mtx_unlock(&priv->mtx);
NG_NODE_UNREF(node);
ng_rmnode_self(node);
} else
mtx_unlock(&priv->mtx);