RDMA/bnxt_re: check debugfs parameter allocation
Subsystems (2)
PATCH 1/1 RDMA/bnxt_re: check debugfs parameter allocation
bnxt_re_debugfs_add_pdev() allocates per-file private data for the CC configuration debugfs entries. The loop that initializes those entries uses rdev->cc_config_params immediately, so allocation failure would lead to NULL pointer dereferences while setting up debugfs.
Debugfs is best-effort. If the CC configuration private data cannot be allocated, skip those entries and continue with the independent CQ coalescing debugfs setup.
--- drivers/infiniband/hw/bnxt_re/debugfs.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/hw/bnxt_re/debugfs.c +3 -0
@@ -498,6 +498,8 @@ void bnxt_re_debugfs_add_pdev(struct bnxt_re_dev *rdev)bnxt_re_debugfs_add_info (rdev); rdev->cc_config_params =kzalloc_obj (*cc_params); +if (!rdev->cc_config_params) + goto init_cq_coal;for (i =0 ; i <BNXT_RE_CC_PARAM_GEN0 ; i++) {struct bnxt_re_cc_param *tmp_params = &rdev->cc_config_params->gen0_parms[i];
@@ -510,6 +512,7 @@ void bnxt_re_debugfs_add_pdev(struct bnxt_re_dev *rdev) &bnxt_re_cc_config_ops); } +init_cq_coal:bnxt_re_init_cq_coal_debugfs (rdev); }
Signature · 1 line
2.34.1
Jason Gunthorpe
maintainerQuoted 5 lines · Ruoyu Wang
bnxt_re_debugfs_add_pdev()allocates per-file private data for the CC configuration debugfs entries. The loop that initializes those entries usesrdev->cc_config_paramsimmediately, so allocation failure would lead to NULL pointer dereferences while setting up debugfs.
Quoted 8 lines
Debugfs is best-effort. If the CC configuration private data cannot be allocated, skip those entries and continue with the independent CQ coalescing debugfs setup.
Signed-off-by Ruoyu Wang <[email protected]>--- drivers/infiniband/hw/bnxt_re/debugfs.c | 3 +++ 1 file changed, 3 insertions(+)
Applied though
drivers/infiniband/hw/bnxt_re/debugfs.c void bnxt_re_debugfs_add_pdev(struct bnxt_re_dev *rdev) · line 502
Quoted 3 lines
drivers/infiniband/hw/bnxt_re/debugfs.c +2
-0rdev->cc_config_params =kzalloc_obj (*cc_params); +if (!rdev->cc_config_params) + goto init_cq_coal;
I changed this to just return, there is no point in continuing to setup as the machine is probably dead if this fails.
Thanks,
Jason