Messages in this thread |  | | Date | Tue, 19 Dec 2023 00:25:16 +0530 | | From | Siddh Raman Pant <> | | Subject | Re: [PATCH net-next v6 1/2] nfc: llcp_core: Hold a ref to llcp_local->dev when holding a ref to llcp_local |
| |
On Mon, 18 Dec 2023 15:09:00 +0530, Krzysztof Kozlowski wrote: > On 17/12/2023 14:11, Siddh Raman Pant wrote: > > static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local, > > @@ -959,8 +974,18 @@ static void nfc_llcp_recv_connect(struct nfc_llcp_local *local, > > } > > > > new_sock = nfc_llcp_sock(new_sk); > > - new_sock->dev = local->dev; > > + > > new_sock->local = nfc_llcp_local_get(local); > > + if (!new_sock->local) { > > + reason = LLCP_DM_REJ; > > + release_sock(&sock->sk); > > + sock_put(&sock->sk); > > + sock_put(&new_sock->sk); > > Why is this needed? Which part earlier gets the reference?
Thanks for pointing out. sk_init sets refcount to 1. Actually on a further look, the next line shouldn't be there as nfc_llcp_sock_free() is already called in sk->sk_destruct (== llcp_sock_destruct()), which is called via __sk_destruct().
As sock_put() -> sk_free() -> __sk_destruct() -> sk_prot_free(), so we need to put.
TBH really don't know why nfc_llcp_sock_free() is not static.
> > + nfc_llcp_sock_free(new_sock); > > This order is still wrong. Unwinding is almost always done in reversed > order, for good reasons. Why do you unwind in other order?
Oops, extremely sorry about that :( I reverted back to wrong ordering from an older local commit and didn't check.
I'll send the fixed one.
Thanks, Siddh
|  |