Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Fix memory leaks pointed out by Ilja Van Sprundel: all
details: https://anonhg.NetBSD.org/src/rev/8bec1ad98854
branches: trunk
changeset: 448280:8bec1ad98854
user: martin <martin%NetBSD.org@localhost>
date: Mon Jan 28 12:53:01 2019 +0000
description:
Fix memory leaks pointed out by Ilja Van Sprundel: all
sendoob() functions are expted to free both passed
mbuf chains.
diffstat:
sys/net/link_proto.c | 7 +++++--
sys/netatalk/ddp_usrreq.c | 8 ++++----
sys/netbt/hci_socket.c | 10 ++++------
sys/netbt/l2cap_socket.c | 10 ++++------
sys/netbt/rfcomm_socket.c | 10 ++++------
sys/netbt/sco_socket.c | 10 ++++------
sys/netinet/sctp_usrreq.c | 10 ++++------
sys/netinet/tcp_usrreq.c | 11 ++++++++---
sys/netinet6/raw_ip6.c | 8 ++++----
sys/netinet6/sctp6_usrreq.c | 10 ++++------
sys/netinet6/udp6_usrreq.c | 10 ++++------
sys/netmpls/mpls_proto.c | 7 +++++--
12 files changed, 54 insertions(+), 57 deletions(-)
diffs (truncated from 379 to 300 lines):
diff -r 8021f6c0808a -r 8bec1ad98854 sys/net/link_proto.c
--- a/sys/net/link_proto.c Mon Jan 28 12:17:28 2019 +0000
+++ b/sys/net/link_proto.c Mon Jan 28 12:53:01 2019 +0000
@@ -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 @@
{
KASSERT(solocked(so));
+ m_freem(m);
+ m_freem(control);
+
return EOPNOTSUPP;
}
diff -r 8021f6c0808a -r 8bec1ad98854 sys/netatalk/ddp_usrreq.c
--- a/sys/netatalk/ddp_usrreq.c Mon Jan 28 12:17:28 2019 +0000
+++ b/sys/netatalk/ddp_usrreq.c Mon Jan 28 12:53:01 2019 +0000
@@ -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 @@
{
KASSERT(solocked(so));
- if (m)
- m_freem(m);
+ m_freem(m);
+ m_freem(control);
return EOPNOTSUPP;
}
diff -r 8021f6c0808a -r 8bec1ad98854 sys/netbt/hci_socket.c
--- a/sys/netbt/hci_socket.c Mon Jan 28 12:17:28 2019 +0000
+++ b/sys/netbt/hci_socket.c Mon Jan 28 12:53:01 2019 +0000
@@ -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 @@
{
KASSERT(solocked(so));
- if (m)
- m_freem(m);
- if (control)
- m_freem(control);
+ m_freem(m);
+ m_freem(control);
return EOPNOTSUPP;
}
diff -r 8021f6c0808a -r 8bec1ad98854 sys/netbt/l2cap_socket.c
--- a/sys/netbt/l2cap_socket.c Mon Jan 28 12:17:28 2019 +0000
+++ b/sys/netbt/l2cap_socket.c Mon Jan 28 12:53:01 2019 +0000
@@ -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 @@
{
KASSERT(solocked(so));
- if (m)
- m_freem(m);
- if (control)
- m_freem(control);
+ m_freem(m);
+ m_freem(control);
return EOPNOTSUPP;
}
diff -r 8021f6c0808a -r 8bec1ad98854 sys/netbt/rfcomm_socket.c
--- a/sys/netbt/rfcomm_socket.c Mon Jan 28 12:17:28 2019 +0000
+++ b/sys/netbt/rfcomm_socket.c Mon Jan 28 12:53:01 2019 +0000
@@ -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 @@
{
KASSERT(solocked(so));
- if (m)
- m_freem(m);
- if (control)
- m_freem(control);
+ m_freem(m);
+ m_freem(control);
return EOPNOTSUPP;
}
diff -r 8021f6c0808a -r 8bec1ad98854 sys/netbt/sco_socket.c
--- a/sys/netbt/sco_socket.c Mon Jan 28 12:17:28 2019 +0000
+++ b/sys/netbt/sco_socket.c Mon Jan 28 12:53:01 2019 +0000
@@ -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 @@
{
KASSERT(solocked(so));
- if (m)
- m_freem(m);
- if (control)
- m_freem(control);
+ m_freem(m);
+ m_freem(control);
return EOPNOTSUPP;
}
diff -r 8021f6c0808a -r 8bec1ad98854 sys/netinet/sctp_usrreq.c
--- a/sys/netinet/sctp_usrreq.c Mon Jan 28 12:17:28 2019 +0000
+++ b/sys/netinet/sctp_usrreq.c Mon Jan 28 12:53:01 2019 +0000
@@ -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 @@
{
KASSERT(solocked(so));
- if (m)
- m_freem(m);
- if (control)
- m_freem(control);
+ m_freem(m);
+ m_freem(control);
return EOPNOTSUPP;
}
diff -r 8021f6c0808a -r 8bec1ad98854 sys/netinet/tcp_usrreq.c
--- a/sys/netinet/tcp_usrreq.c Mon Jan 28 12:17:28 2019 +0000
+++ b/sys/netinet/tcp_usrreq.c Mon Jan 28 12:53:01 2019 +0000
@@ -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 @@
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 @@
tp->t_force = 0;
tcp_debug_trace(so, tp, ostate, PRU_SENDOOB);
splx(s);
+ m_freem(control);
return error;
}
diff -r 8021f6c0808a -r 8bec1ad98854 sys/netinet6/raw_ip6.c
--- a/sys/netinet6/raw_ip6.c Mon Jan 28 12:17:28 2019 +0000
+++ b/sys/netinet6/raw_ip6.c Mon Jan 28 12:53:01 2019 +0000
@@ -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 @@
{
KASSERT(solocked(so));
- if (m)
- m_freem(m);
+ m_freem(m);
+ m_freem(control);
return EOPNOTSUPP;
}
diff -r 8021f6c0808a -r 8bec1ad98854 sys/netinet6/sctp6_usrreq.c
--- a/sys/netinet6/sctp6_usrreq.c Mon Jan 28 12:17:28 2019 +0000
+++ b/sys/netinet6/sctp6_usrreq.c Mon Jan 28 12:53:01 2019 +0000
@@ -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.
Home |
Main Index |
Thread Index |
Old Index