From 5364e465021704eb96261e528ce921922bc3d713 Mon Sep 17 00:00:00 2001 From: riastradh Date: Thu, 16 Jun 2016 15:18:33 +0000 Subject: [PATCH] Fix error branches of if_sdl_sysctl. Can't release the psref if we didn't even find the interface! --- sys/net/if.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 161a21a95f46..a5bee74c9fd7 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $NetBSD: if.c,v 1.340 2016/06/16 03:03:33 ozaki-r Exp $ */ +/* $NetBSD: if.c,v 1.341 2016/06/16 15:18:33 riastradh Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc. @@ -90,7 +90,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.340 2016/06/16 03:03:33 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.341 2016/06/16 15:18:33 riastradh Exp $"); #if defined(_KERNEL_OPT) #include "opt_inet.h" @@ -3108,25 +3108,26 @@ if_sdl_sysctl(SYSCTLFN_ARGS) ifp = if_get_byindex(name[0], &psref); if (ifp == NULL) { error = ENODEV; - goto out; + goto out0; } sdl = ifp->if_sadl; if (sdl == NULL) { *oldlenp = 0; - goto out; + goto out1; } if (oldp == NULL) { *oldlenp = sdl->sdl_alen; - goto out; + goto out1; } if (*oldlenp >= sdl->sdl_alen) *oldlenp = sdl->sdl_alen; error = sysctl_copyout(l, &sdl->sdl_data[sdl->sdl_nlen], oldp, *oldlenp); -out: +out1: if_put(ifp, &psref); +out0: curlwp_bindx(bound); return error; }