Skip to contentSkip to conversation

iw_cxgb4: potential NULL dereference in c4iw_fill_res_cm_id_entry()

PATCH Applied Dan Carpenter 2 participants 2 messages Feb 14, 2023 – Feb 15, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iw_cxgb4: potential NULL dereference in c4iw_fill_res_cm_id_entry()

This condition needs to match the previous "if (epcp->state == LISTEN) {" exactly to avoid a NULL dereference of either "listen_ep" or "ep". The problem is that "epcp" has been re-assigned so just testing "if (epcp->state == LISTEN) {" a second time is not sufficient.

Fixes 116aeb887371 ("iw_cxgb4: provide detailed provider-specific CM_ID information")

---
From static analysis, not from testing. It's possible that the current code works but this change makes it more Obviously Correct[tm].

 drivers/infiniband/hw/cxgb4/restrack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/cxgb4/restrack.c +1 -1
index ff645b955a08..fd22c85d35f4 100644
@@ -238,7 +238,7 @@ int c4iw_fill_res_cm_id_entry(struct sk_buff *msg,
 	if (rdma_nl_put_driver_u64_hex(msg, "history", epcp->history))
 		goto err_cancel_table;
 
-	if (epcp->state == LISTEN) {
+	if (listen_ep) {
 		if (rdma_nl_put_driver_u32(msg, "stid", listen_ep->stid))
 			goto err_cancel_table;
 		if (rdma_nl_put_driver_u32(msg, "backlog", listen_ep->backlog))
Signature · 1 line
2.35.1
#1 lore raw
Quoted 6 lines · Dan Carpenter

This condition needs to match the previous "if (epcp->state == LISTEN) {" exactly to avoid a NULL dereference of either "listen_ep" or "ep". The problem is that "epcp" has been re-assigned so just testing "if (epcp->state == LISTEN) {" a second time is not sufficient.

Applied, thanks!

[1/1] iw_cxgb4: potential NULL dereference in c4iw_fill_res_cm_id_entry()

      https://git.kernel.org/rdma/rdma/c/4ca446b127c568

Best regards,

Signature · 1 line
Leon Romanovsky <[email protected]>