Skip to contentSkip to conversation

NFC: only put local on destruction if it was created before

PATCH In review Sasha Levin 2 participants 4 messages Jun 12, 2012 – Jun 25, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFC: only put local on destruction if it was created before

Not having 'local' is a valid case when a socket was created but never bound or connected to anything, so avoid putting 'local' if it was never created.

---
 net/nfc/llcp/sock.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
net/nfc/llcp/sock.c +2 -1
index 2c0b317..54daa10 100644
@@ -710,7 +710,8 @@ void nfc_llcp_sock_free(struct nfc_llcp_sock *sock)
 
 	sock->parent = NULL;
 
-	nfc_llcp_local_put(sock->local);
+	if (sock->local)
+		nfc_llcp_local_put(sock->local);
 }
 
 static int llcp_sock_create(struct net *net, struct socket *sock,
Signature · 1 line
1.7.8.6
#1 lore raw

Hi Sasha,

Quoted 14 lines · Sasha Levin

Not having 'local' is a valid case when a socket was created but never bound or connected to anything, so avoid putting 'local' if it was never created.

---
 net/nfc/llcp/sock.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
net/nfc/llcp/sock.c +0 -0
index 2c0b317..54daa10 100644

net/nfc/llcp/sock.c void nfc_llcp_sock_free(struct nfc_llcp_sock *sock) · line 714

Quoted 6 lines
net/nfc/llcp/sock.c +2 -1
@@ -710,7 +710,8 @@ void nfc_llcp_sock_free(struct nfc_llcp_sock *sock)
 
 	sock->parent = NULL;
 
-	nfc_llcp_local_put(sock->local);
+	if (sock->local)
+		nfc_llcp_local_put(sock->local);

nfc_llcp_local_put() already checks for its argument being NULL or not.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#2 lore raw
Quoted 18 lines · Samuel Ortiz

Hi Sasha,

Quoted 15 lines · Sasha Levin

Not having 'local' is a valid case when a socket was created but never bound or connected to anything, so avoid putting 'local' if it was never created.

---
 net/nfc/llcp/sock.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
net/nfc/llcp/sock.c +0 -0
index 2c0b317..54daa10 100644
@@ -710,7 +710,8 @@ void nfc_llcp_sock_free(struct nfc_llcp_sock *sock)
 
Quoted 6 lines

net/nfc/llcp/sock.c void nfc_llcp_sock_free(struct nfc_llcp_sock *sock) · line 714

Quoted 5 lines
net/nfc/llcp/sock.c +2 -1
 	sock->parent = NULL;
 
-	nfc_llcp_local_put(sock->local);
+	if (sock->local)
+		nfc_llcp_local_put(sock->local);

nfc_llcp_local_put() already checks for its argument being NULL or not.

nfc_llcp_local_put() triggers a warning in this case as well, which means that this code path shouldn't be happening.

Should we remove the WARN_ON from nfc_llcp_local_put() instead?

#3 lore raw
Quoted 26 lines · Sasha Levin
Quoted 18 lines · Samuel Ortiz

Hi Sasha,

Quoted 15 lines · Sasha Levin

Not having 'local' is a valid case when a socket was created but never bound or connected to anything, so avoid putting 'local' if it was never created.

---
 net/nfc/llcp/sock.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
net/nfc/llcp/sock.c +0 -0
index 2c0b317..54daa10 100644
@@ -710,7 +710,8 @@ void nfc_llcp_sock_free(struct nfc_llcp_sock *sock)
 
Quoted 6 lines

net/nfc/llcp/sock.c void nfc_llcp_sock_free(struct nfc_llcp_sock *sock) · line 714

Quoted 5 lines
net/nfc/llcp/sock.c +2 -1
 	sock->parent = NULL;
 
-	nfc_llcp_local_put(sock->local);
+	if (sock->local)
+		nfc_llcp_local_put(sock->local);

nfc_llcp_local_put() already checks for its argument being NULL or not.

Quoted 4 lines

nfc_llcp_local_put() triggers a warning in this case as well, which means that this code path shouldn't be happening.

Should we remove the WARN_ON from nfc_llcp_local_put() instead?

Yes, that would be better.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/