net/mlx5e: kTLS, Add debugfs
Hello Tariq Toukan,
The patch 0fedee1ae9ef: "net/mlx5e: kTLS, Add debugfs" from May 3, 2022, leads to the following Smatch static checker warning:
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c:897 mlx5e_tls_tx_debugfs_init() warn: 'tls->debugfs.dfs_tx' is an error pointer or valid
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
890 static void mlx5e_tls_tx_debugfs_init(struct mlx5e_tls *tls,
891 struct dentry *dfs_root)
892 {
893 if (IS_ERR_OR_NULL(dfs_root))
894 return;
895
896 tls->debugfs.dfs_tx = debugfs_create_dir("tx", dfs_root);--> 897 if (!tls->debugfs.dfs_tx)
This isn't NULL, but also the correct way to write debugsf code is to delete the error checking. There are some exceptions where the driver dereferences ->dfs_tx directly to get the inode size or whatever, but it doesn't apply in this case.
898 return;
899
900 debugfs_create_size_t("pool_size", 0400, tls->debugfs.dfs_tx,
901 &tls->tx_pool->size);
902 }regards,
dan carpenter
Quoted 23 lines · Dan Carpenter
Hello Tariq Toukan,
The patch
0fedee1ae9ef: "net/mlx5e: kTLS, Add debugfs" from May 3, 2022, leads to the following Smatch static checker warning:drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c:897 mlx5e_tls_tx_debugfs_init() warn: 'tls->debugfs.dfs_tx' is an error pointer or valid
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c890 static void mlx5e_tls_tx_debugfs_init(struct mlx5e_tls *tls, 891 struct dentry *dfs_root) 892 { 893 if (IS_ERR_OR_NULL(dfs_root)) 894 return; 895 896 tls->debugfs.dfs_tx = debugfs_create_dir("tx", dfs_root);--> 897 if (!tls->debugfs.dfs_tx)
This isn't NULL, but also the correct way to write debugsf code is to delete the error checking. There are some exceptions where the driver dereferences ->dfs_tx directly to get the inode size or whatever, but it doesn't apply in this case.
Quoted 8 lines
898 return; 899 900 debugfs_create_size_t("pool_size", 0400, tls->debugfs.dfs_tx, 901 &tls->tx_pool->size); 902 }regards,
dan carpenter
Hi Dan,
Thanks for your report.
We'll analyze and handle soon.
Regards,
Tariq