[PATCH net] nfc: nci: free destination parameters when closing a connection

Linmao Li posted 1 patch 3 days, 22 hours ago
net/nfc/nci/rsp.c | 1 +
1 file changed, 1 insertion(+)
[PATCH net] nfc: nci: free destination parameters when closing a connection
Posted by Linmao Li 3 days, 22 hours ago
When a connection is closed, nci_core_conn_close_rsp_packet() frees
conn_info but not conn_info->dest_params, which is a separate devm
allocation. Each connect/close cycle leaks one dest_params until the
NFC device is removed. Free dest_params along with conn_info.

Fixes: 9b8d1a4cf2aa ("nfc: nci: Add an additional parameter to identify a connection id")
Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
---
 net/nfc/nci/rsp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/nfc/nci/rsp.c b/net/nfc/nci/rsp.c
index 6b2fa6bdbd14..21c2fe64490e 100644
--- a/net/nfc/nci/rsp.c
+++ b/net/nfc/nci/rsp.c
@@ -360,6 +360,7 @@ static void nci_core_conn_close_rsp_packet(struct nci_dev *ndev,
 			list_del(&conn_info->list);
 			if (conn_info == ndev->rf_conn_info)
 				ndev->rf_conn_info = NULL;
+			devm_kfree(&ndev->nfc_dev->dev, conn_info->dest_params);
 			devm_kfree(&ndev->nfc_dev->dev, conn_info);
 		}
 	}
-- 
2.25.1
Re: [PATCH net] nfc: nci: free destination parameters when closing a connection
Posted by Vadim Fedorenko 3 days, 15 hours ago
On 21/07/2026 03:35, Linmao Li wrote:
> When a connection is closed, nci_core_conn_close_rsp_packet() frees
> conn_info but not conn_info->dest_params, which is a separate devm
> allocation. Each connect/close cycle leaks one dest_params until the
> NFC device is removed. Free dest_params along with conn_info.
> 
> Fixes: 9b8d1a4cf2aa ("nfc: nci: Add an additional parameter to identify a connection id")
> Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
> ---
>   net/nfc/nci/rsp.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/net/nfc/nci/rsp.c b/net/nfc/nci/rsp.c
> index 6b2fa6bdbd14..21c2fe64490e 100644
> --- a/net/nfc/nci/rsp.c
> +++ b/net/nfc/nci/rsp.c
> @@ -360,6 +360,7 @@ static void nci_core_conn_close_rsp_packet(struct nci_dev *ndev,
>   			list_del(&conn_info->list);
>   			if (conn_info == ndev->rf_conn_info)
>   				ndev->rf_conn_info = NULL;
> +			devm_kfree(&ndev->nfc_dev->dev, conn_info->dest_params);
>   			devm_kfree(&ndev->nfc_dev->dev, conn_info);
>   		}
>   	}

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>