summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2006-07-19 18:28:52 +0000
committerjhb <jhb@FreeBSD.org>2006-07-19 18:28:52 +0000
commit947b8c9fbd64c828ef441411fff4f0ce542a99e2 (patch)
treef118230bba024980cf53524a675fa4cf555e0f6a
parentde5f3a26d7a77dc461ed2c15145b9b2ba0386750 (diff)
downloadFreeBSD-src-947b8c9fbd64c828ef441411fff4f0ce542a99e2.zip
FreeBSD-src-947b8c9fbd64c828ef441411fff4f0ce542a99e2.tar.gz
Don't free the sockaddr in kern_bind() and kern_connect() as not all
callers pass a sockaddr allocated via malloc() from M_SONAME anymore. Instead, free it in the callers when necessary.
-rw-r--r--sys/compat/linux/linux_socket.c5
-rw-r--r--sys/kern/uipc_syscalls.c10
2 files changed, 10 insertions, 5 deletions
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
index 8b164fa..3f089c0 100644
--- a/sys/compat/linux/linux_socket.c
+++ b/sys/compat/linux/linux_socket.c
@@ -609,7 +609,9 @@ linux_bind(struct thread *td, struct linux_bind_args *args)
if (error)
return (error);
- return (kern_bind(td, linux_args.s, sa));
+ error = kern_bind(td, linux_args.s, sa);
+ free(sa, M_SONAME);
+ return (error);
}
struct linux_connect_args {
@@ -638,6 +640,7 @@ linux_connect(struct thread *td, struct linux_connect_args *args)
return (error);
error = kern_connect(td, linux_args.s, sa);
+ free(sa, M_SONAME);
if (error != EISCONN)
return (error);
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 76a66a4..a9eaa0d 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -209,7 +209,9 @@ bind(td, uap)
if ((error = getsockaddr(&sa, uap->name, uap->namelen)) != 0)
return (error);
- return (kern_bind(td, uap->s, sa));
+ error = kern_bind(td, uap->s, sa);
+ free(sa, M_SONAME);
+ return (error);
}
int
@@ -241,7 +243,6 @@ done1:
fdrop(fp, td);
done2:
NET_UNLOCK_GIANT();
- FREE(sa, M_SONAME);
return (error);
}
@@ -534,7 +535,9 @@ connect(td, uap)
if (error)
return (error);
- return (kern_connect(td, uap->s, sa));
+ error = kern_connect(td, uap->s, sa);
+ free(sa, M_SONAME);
+ return (error);
}
@@ -596,7 +599,6 @@ done1:
fdrop(fp, td);
done2:
NET_UNLOCK_GIANT();
- FREE(sa, M_SONAME);
return (error);
}
OpenPOWER on IntegriCloud