Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1309459
| From | Rainer Weikusat <rweikusat@mobileactivedefense.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] af_unix: Use kfree for addresses in unix_bind |
| Date | 2016-01-14 17:30 +0100 |
| Message-ID | <qQSWC-197-21@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
Use kfree instead of unix_release_addr when freeing newly-allocated
unix_address structures after binding the socket failed. The second
function does an atomic_dec_and_test in order to free the address once
its reference count falls to zero which isn't necessary for the
unix_bind error path as the new structure wasn't published yet. 'Using
kfree' is also how unix_autobind handles this case.
Signed-off-by: Rainer Weikusat <rweikusat@mobileactivedefense.com>
---
gdiff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index c5bf5ef..b894a3c 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1044,7 +1044,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
if (err) {
if (err == -EEXIST)
err = -EADDRINUSE;
- unix_release_addr(addr);
+ kfree(addr);
goto out_up;
}
addr->hash = UNIX_HASH_SIZE;
@@ -1057,7 +1057,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
err = -EADDRINUSE;
if (__unix_find_socket_byname(net, sunaddr, addr_len,
sk->sk_type, hash)) {
- unix_release_addr(addr);
+ kfree(addr);
goto out_unlock;
}
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] af_unix: Use kfree for addresses in unix_bind Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2016-01-14 17:30 +0100
Re: [PATCH] af_unix: Use kfree for addresses in unix_bind Eric Dumazet <eric.dumazet@gmail.com> - 2016-01-14 19:10 +0100
Re: [PATCH] af_unix: Use kfree for addresses in unix_bind Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2016-01-14 20:10 +0100
csiph-web