Fix memory leaks pointed out by Ilja Van Sprundel: all

sendoob() functions are expted to free both passed
mbuf chains.
This commit is contained in:
martin 2019-01-28 12:53:01 +00:00
parent 71ad2c37b2
commit dc194ae5f0
12 changed files with 54 additions and 57 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: link_proto.c,v 1.36 2017/04/06 03:55:00 ozaki-r Exp $ */
/* $NetBSD: link_proto.c,v 1.37 2019/01/28 12:53:01 martin Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: link_proto.c,v 1.36 2017/04/06 03:55:00 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: link_proto.c,v 1.37 2019/01/28 12:53:01 martin Exp $");
#include <sys/param.h>
#include <sys/socket.h>
@ -401,6 +401,9 @@ link_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
{
KASSERT(solocked(so));
m_freem(m);
m_freem(control);
return EOPNOTSUPP;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ddp_usrreq.c,v 1.71 2018/02/17 19:10:18 rjs Exp $ */
/* $NetBSD: ddp_usrreq.c,v 1.72 2019/01/28 12:53:01 martin Exp $ */
/*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.71 2018/02/17 19:10:18 rjs Exp $");
__KERNEL_RCSID(0, "$NetBSD: ddp_usrreq.c,v 1.72 2019/01/28 12:53:01 martin Exp $");
#include "opt_mbuftrace.h"
#include "opt_atalk.h"
@ -519,8 +519,8 @@ ddp_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
{
KASSERT(solocked(so));
if (m)
m_freem(m);
m_freem(m);
m_freem(control);
return EOPNOTSUPP;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: hci_socket.c,v 1.45 2015/12/22 11:40:07 plunky Exp $ */
/* $NetBSD: hci_socket.c,v 1.46 2019/01/28 12:53:01 martin Exp $ */
/*-
* Copyright (c) 2005 Iain Hibbert.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: hci_socket.c,v 1.45 2015/12/22 11:40:07 plunky Exp $");
__KERNEL_RCSID(0, "$NetBSD: hci_socket.c,v 1.46 2019/01/28 12:53:01 martin Exp $");
/* load symbolic names */
#ifdef BLUETOOTH_DEBUG
@ -690,10 +690,8 @@ hci_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
{
KASSERT(solocked(so));
if (m)
m_freem(m);
if (control)
m_freem(control);
m_freem(m);
m_freem(control);
return EOPNOTSUPP;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: l2cap_socket.c,v 1.35 2015/05/02 17:18:03 rtr Exp $ */
/* $NetBSD: l2cap_socket.c,v 1.36 2019/01/28 12:53:01 martin Exp $ */
/*-
* Copyright (c) 2005 Iain Hibbert.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: l2cap_socket.c,v 1.35 2015/05/02 17:18:03 rtr Exp $");
__KERNEL_RCSID(0, "$NetBSD: l2cap_socket.c,v 1.36 2019/01/28 12:53:01 martin Exp $");
/* load symbolic names */
#ifdef BLUETOOTH_DEBUG
@ -338,10 +338,8 @@ l2cap_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
{
KASSERT(solocked(so));
if (m)
m_freem(m);
if (control)
m_freem(control);
m_freem(m);
m_freem(control);
return EOPNOTSUPP;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rfcomm_socket.c,v 1.37 2015/05/02 17:18:03 rtr Exp $ */
/* $NetBSD: rfcomm_socket.c,v 1.38 2019/01/28 12:53:01 martin Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rfcomm_socket.c,v 1.37 2015/05/02 17:18:03 rtr Exp $");
__KERNEL_RCSID(0, "$NetBSD: rfcomm_socket.c,v 1.38 2019/01/28 12:53:01 martin Exp $");
/* load symbolic names */
#ifdef BLUETOOTH_DEBUG
@ -343,10 +343,8 @@ rfcomm_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
{
KASSERT(solocked(so));
if (m)
m_freem(m);
if (control)
m_freem(control);
m_freem(m);
m_freem(control);
return EOPNOTSUPP;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: sco_socket.c,v 1.37 2015/05/02 17:18:03 rtr Exp $ */
/* $NetBSD: sco_socket.c,v 1.38 2019/01/28 12:53:01 martin Exp $ */
/*-
* Copyright (c) 2006 Itronix Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sco_socket.c,v 1.37 2015/05/02 17:18:03 rtr Exp $");
__KERNEL_RCSID(0, "$NetBSD: sco_socket.c,v 1.38 2019/01/28 12:53:01 martin Exp $");
/* load symbolic names */
#ifdef BLUETOOTH_DEBUG
@ -329,10 +329,8 @@ sco_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
{
KASSERT(solocked(so));
if (m)
m_freem(m);
if (control)
m_freem(control);
m_freem(m);
m_freem(control);
return EOPNOTSUPP;
}

View File

@ -1,5 +1,5 @@
/* $KAME: sctp_usrreq.c,v 1.50 2005/06/16 20:45:29 jinmei Exp $ */
/* $NetBSD: sctp_usrreq.c,v 1.13 2018/09/03 16:29:36 riastradh Exp $ */
/* $NetBSD: sctp_usrreq.c,v 1.14 2019/01/28 12:53:01 martin Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
@ -33,7 +33,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sctp_usrreq.c,v 1.13 2018/09/03 16:29:36 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: sctp_usrreq.c,v 1.14 2019/01/28 12:53:01 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -3824,10 +3824,8 @@ sctp_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
{
KASSERT(solocked(so));
if (m)
m_freem(m);
if (control)
m_freem(control);
m_freem(m);
m_freem(control);
return EOPNOTSUPP;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: tcp_usrreq.c,v 1.222 2018/12/16 17:46:58 christos Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.223 2019/01/28 12:53:01 martin Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -99,7 +99,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.222 2018/12/16 17:46:58 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.223 2019/01/28 12:53:01 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -1148,14 +1148,18 @@ tcp_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
int error = 0;
int s;
if ((error = tcp_getpcb(so, &inp, &in6p, &tp)) != 0)
if ((error = tcp_getpcb(so, &inp, &in6p, &tp)) != 0) {
m_freem(m);
m_freem(control);
return error;
}
ostate = tcp_debug_capture(tp, PRU_SENDOOB);
s = splsoftnet();
if (sbspace_oob(&so->so_snd) == 0) {
m_freem(m);
m_freem(control);
splx(s);
return ENOBUFS;
}
@ -1174,6 +1178,7 @@ tcp_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
tp->t_force = 0;
tcp_debug_trace(so, tp, ostate, PRU_SENDOOB);
splx(s);
m_freem(control);
return error;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: raw_ip6.c,v 1.172 2018/05/11 14:25:50 maxv Exp $ */
/* $NetBSD: raw_ip6.c,v 1.173 2019/01/28 12:53:01 martin Exp $ */
/* $KAME: raw_ip6.c,v 1.82 2001/07/23 18:57:56 jinmei Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.172 2018/05/11 14:25:50 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: raw_ip6.c,v 1.173 2019/01/28 12:53:01 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@ -905,8 +905,8 @@ rip6_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
{
KASSERT(solocked(so));
if (m)
m_freem(m);
m_freem(m);
m_freem(control);
return EOPNOTSUPP;
}

View File

@ -1,5 +1,5 @@
/* $KAME: sctp6_usrreq.c,v 1.38 2005/08/24 08:08:56 suz Exp $ */
/* $NetBSD: sctp6_usrreq.c,v 1.16 2018/05/01 07:21:39 maxv Exp $ */
/* $NetBSD: sctp6_usrreq.c,v 1.17 2019/01/28 12:53:01 martin Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc.
@ -33,7 +33,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sctp6_usrreq.c,v 1.16 2018/05/01 07:21:39 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: sctp6_usrreq.c,v 1.17 2019/01/28 12:53:01 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -912,10 +912,8 @@ sctp6_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
{
KASSERT(solocked(so));
if (m)
m_freem(m);
if (control)
m_freem(control);
m_freem(m);
m_freem(control);
return EOPNOTSUPP;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: udp6_usrreq.c,v 1.145 2018/12/27 16:59:17 maxv Exp $ */
/* $NetBSD: udp6_usrreq.c,v 1.146 2019/01/28 12:53:01 martin Exp $ */
/* $KAME: udp6_usrreq.c,v 1.86 2001/05/27 17:33:00 itojun Exp $ */
/* $KAME: udp6_output.c,v 1.43 2001/10/15 09:19:52 itojun Exp $ */
@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.145 2018/12/27 16:59:17 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: udp6_usrreq.c,v 1.146 2019/01/28 12:53:01 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -1279,10 +1279,8 @@ udp6_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
{
KASSERT(solocked(so));
if (m)
m_freem(m);
if (control)
m_freem(control);
m_freem(m);
m_freem(control);
return EOPNOTSUPP;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: mpls_proto.c,v 1.31 2017/09/21 07:15:35 ozaki-r Exp $ */
/* $NetBSD: mpls_proto.c,v 1.32 2019/01/28 12:53:01 martin Exp $ */
/*
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mpls_proto.c,v 1.31 2017/09/21 07:15:35 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: mpls_proto.c,v 1.32 2019/01/28 12:53:01 martin Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -221,6 +221,9 @@ mpls_sendoob(struct socket *so, struct mbuf *m, struct mbuf *control)
{
KASSERT(solocked(so));
m_freem(m);
m_freem(control);
return EOPNOTSUPP;
}