[PATCH 19.11] net/mlx5: cleanup Netlink interrupt handler

Dmitry Kozlyuk dkozlyuk at nvidia.com
Thu Sep 8 11:34:08 CEST 2022


[ upstream commit 17f95513adca1f4ee5bba305b154ac984ee50cee ]

When the upstream commit was backported by the offending commit,
the cleanup part of the fix was missed. The interrupt handler
was not unregistered and the Netlink socket was not closed
with the device closing. The socket was leaking and the handler
could continue working with random content in the freed memory:

    net_mlx5: Failed to process Netlink events: \
        Socket operation on non-socket

Fixes: edea6144b47f ("net/mlx5: fix link status change detection")

Signed-off-by: Dmitry Kozlyuk <dkozlyuk at nvidia.com>
Acked-by: Suanming Mou <suanmingm at nvidia.com>
---
 drivers/net/mlx5/mlx5.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index dee018bbba..f3b440635e 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -579,6 +579,11 @@ mlx5_dev_shared_handler_uninstall(struct mlx5_ibv_shared *sh)
 	if (sh->intr_handle.fd >= 0)
 		mlx5_intr_callback_unregister(&sh->intr_handle,
 					      mlx5_dev_interrupt_handler, sh);
+	if (sh->intr_handle_nl.fd >= 0) {
+		mlx5_intr_callback_unregister(&sh->intr_handle_nl,
+					      mlx5_dev_interrupt_handler_nl, sh);
+		close(sh->intr_handle_nl.fd);
+	}
 #ifdef HAVE_IBV_DEVX_ASYNC
 	if (sh->intr_handle_devx.fd >= 0)
 		rte_intr_callback_unregister(&sh->intr_handle_devx,
-- 
2.25.1



More information about the stable mailing list