Skip to content

Commit f8a3db4

Browse files
dtatuleamstsirkin
authored andcommitted
vdpa/mlx5: Fix double release of debugfs entry
The error path in setup_driver deletes the debugfs entry but doesn't clear the pointer. During .dev_del the invalid pointer will be released again causing a crash. This patch fixes the issue by always clearing the debugfs entry in mlx5_vdpa_remove_debugfs. Also, stop removing the debugfs entry in .dev_del op: the debugfs entry is already handled within the setup_driver/teardown_driver scope. Cc: [email protected] Fixes: f0417e7 ("vdpa/mlx5: Add and remove debugfs in setup/teardown driver") Signed-off-by: Dragos Tatulea <[email protected]> Reviewed-by: Gal Pressman <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Acked-by: Jason Wang <[email protected]>
1 parent fab7f25 commit f8a3db4

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

drivers/vdpa/mlx5/net/debug.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ void mlx5_vdpa_add_debugfs(struct mlx5_vdpa_net *ndev)
146146
ndev->rx_dent = debugfs_create_dir("rx", ndev->debugfs);
147147
}
148148

149-
void mlx5_vdpa_remove_debugfs(struct dentry *dbg)
149+
void mlx5_vdpa_remove_debugfs(struct mlx5_vdpa_net *ndev)
150150
{
151-
debugfs_remove_recursive(dbg);
151+
debugfs_remove_recursive(ndev->debugfs);
152+
ndev->debugfs = NULL;
152153
}

drivers/vdpa/mlx5/net/mlx5_vnet.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,7 +2713,7 @@ static int setup_driver(struct mlx5_vdpa_dev *mvdev)
27132713
err_rqt:
27142714
teardown_virtqueues(ndev);
27152715
err_setup:
2716-
mlx5_vdpa_remove_debugfs(ndev->debugfs);
2716+
mlx5_vdpa_remove_debugfs(ndev);
27172717
out:
27182718
return err;
27192719
}
@@ -2727,8 +2727,7 @@ static void teardown_driver(struct mlx5_vdpa_net *ndev)
27272727
if (!ndev->setup)
27282728
return;
27292729

2730-
mlx5_vdpa_remove_debugfs(ndev->debugfs);
2731-
ndev->debugfs = NULL;
2730+
mlx5_vdpa_remove_debugfs(ndev);
27322731
teardown_steering(ndev);
27332732
destroy_tir(ndev);
27342733
destroy_rqt(ndev);
@@ -3489,8 +3488,6 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device *
34893488
struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev);
34903489
struct workqueue_struct *wq;
34913490

3492-
mlx5_vdpa_remove_debugfs(ndev->debugfs);
3493-
ndev->debugfs = NULL;
34943491
unregister_link_notifier(ndev);
34953492
_vdpa_unregister_device(dev);
34963493
wq = mvdev->wq;

drivers/vdpa/mlx5/net/mlx5_vnet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct macvlan_node {
8888
};
8989

9090
void mlx5_vdpa_add_debugfs(struct mlx5_vdpa_net *ndev);
91-
void mlx5_vdpa_remove_debugfs(struct dentry *dbg);
91+
void mlx5_vdpa_remove_debugfs(struct mlx5_vdpa_net *ndev);
9292
void mlx5_vdpa_add_rx_flow_table(struct mlx5_vdpa_net *ndev);
9393
void mlx5_vdpa_remove_rx_flow_table(struct mlx5_vdpa_net *ndev);
9494
void mlx5_vdpa_add_tirn(struct mlx5_vdpa_net *ndev);

0 commit comments

Comments
 (0)