From a9252649d3c7afe4a8ecb590e876d29a1a4c2bc3 Mon Sep 17 00:00:00 2001 From: mvs Date: Mon, 15 Feb 2021 19:01:30 +0000 Subject: [PATCH] Simplify error path in in route_attach(). We always call it in thread context so we always have `curproc' Also protocol control block is not required for soreserve() so we can do it before `rop' allocation. ok bluhm@ --- sys/net/rtsock.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 65214a9dd1d..f5f86e9f0e2 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.304 2020/11/07 09:51:40 denis Exp $ */ +/* $OpenBSD: rtsock.c,v 1.305 2021/02/15 19:01:30 mvs Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -301,6 +301,9 @@ route_attach(struct socket *so, int proto) struct rtpcb *rop; int error; + error = soreserve(so, ROUTESNDQ, ROUTERCVQ); + if (error) + return (error); /* * use the rawcb but allocate a rtpcb, this * code does not care about the additional fields @@ -312,15 +315,6 @@ route_attach(struct socket *so, int proto) timeout_set(&rop->rop_timeout, rtm_senddesync_timer, so); refcnt_init(&rop->rop_refcnt); - if (curproc == NULL) - error = EACCES; - else - error = soreserve(so, ROUTESNDQ, ROUTERCVQ); - if (error) { - pool_put(&rtpcb_pool, rop); - return (error); - } - rop->rop_socket = so; rop->rop_proto = proto; -- 2.20.1