public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] af_unix: Use kfree for addresses in unix_bind
@ 2016-01-14 16:22 Rainer Weikusat
  2016-01-14 18:00 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Rainer Weikusat @ 2016-01-14 16:22 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel

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;
 		}
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-14 19:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-14 16:22 [PATCH] af_unix: Use kfree for addresses in unix_bind Rainer Weikusat
2016-01-14 18:00 ` Eric Dumazet
2016-01-14 19:05   ` Rainer Weikusat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox