[PATCH, net-next] net/mlx5: Use kfree() to match kzalloc_obj() in mlx5_events_cleanup()

lirongqing posted 1 patch 1 month, 1 week ago
drivers/net/ethernet/mellanox/mlx5/core/events.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH, net-next] net/mlx5: Use kfree() to match kzalloc_obj() in mlx5_events_cleanup()
Posted by lirongqing 1 month, 1 week ago
From: Li RongQing <lirongqing@baidu.com>

dev->priv.events is allocated in mlx5_events_init() with kzalloc_obj(),
which is a kmalloc-family allocator, so it must be released with kfree().

kvfree() happens to work here because it falls back to kfree() for
non-vmalloc addresses, but it is semantically imprecise. Use kfree() to
correctly pair with the allocation and to match the error path in
mlx5_events_init(), which already uses kfree(events).

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/events.c b/drivers/net/ethernet/mellanox/mlx5/core/events.c
index 4d7f35b..fc5ecce 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/events.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/events.c
@@ -396,7 +396,7 @@ int mlx5_events_init(struct mlx5_core_dev *dev)
 void mlx5_events_cleanup(struct mlx5_core_dev *dev)
 {
 	destroy_workqueue(dev->priv.events->wq);
-	kvfree(dev->priv.events);
+	kfree(dev->priv.events);
 }
 
 void mlx5_events_start(struct mlx5_core_dev *dev)
-- 
2.9.4
Re: [PATCH, net-next] net/mlx5: Use kfree() to match kzalloc_obj() in mlx5_events_cleanup()
Posted by Jakub Kicinski 1 month, 1 week ago
On Tue, 18 Aug 2026 20:25:30 +0800 lirongqing wrote:
> dev->priv.events is allocated in mlx5_events_init() with kzalloc_obj(),
> which is a kmalloc-family allocator, so it must be released with kfree().

## Form letter - net-next-closed

The merge window for v7.3 has started, and therefore net-next is closed
for new drivers, features, code refactoring and optimizations.
We will only consider applying net-next patches which were posted
before the announcement:

https://lore.kernel.org/20260816155953.072d73da@kernel.org

Fixes are obviously welcome at any time. net-next patches may be sent
for review and discussion only with an RFC tag.

Please repost when net-next reopens.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle
-- 
pw-bot: defer
pv-bot: closed