Skip to contentSkip to conversation

RDMA/rxe: Replace pr_xxx by rxe_dbg_xxx in rxe_mr.c

bug report Dan Carpenter 2 participants 2 messages Nov 18, 2022 – Nov 22, 2022

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

Hello Bob Pearson,

This is a semi-automatic email about new static checker warnings.

The patch 2778b72b1df0: "RDMA/rxe: Replace pr_xxx by rxe_dbg_xxx in rxe_mr.c" from Nov 3, 2022, leads to the following Smatch complaint:

drivers/infiniband/sw/rxe/rxe_mr.c:527 rxe_invalidate_mr()
error: we previously assumed 'mr' could be null (see line 526)

drivers/infiniband/sw/rxe/rxe_mr.c
525 mr = rxe_pool_get_index(&rxe->mr_pool, key >> 8);

   526		if (!mr) {
                    ^^^

"mr" is NULL.

527 rxe_dbg_mr(mr, "No MR for key %#x\n", key);

                                   ^^

Dereference.

   528			ret = -EINVAL;
   529			goto err;

regards,
dan carpenter

#1 lore raw
Quoted 14 lines · Dan Carpenter

Hello Bob Pearson,

This is a semi-automatic email about new static checker warnings.

The patch 2778b72b1df0: "RDMA/rxe: Replace pr_xxx by rxe_dbg_xxx in rxe_mr.c" from Nov 3, 2022, leads to the following Smatch complaint:

drivers/infiniband/sw/rxe/rxe_mr.c:527 rxe_invalidate_mr()
error: we previously assumed 'mr' could be null (see line 526)

drivers/infiniband/sw/rxe/rxe_mr.c

   525		mr = rxe_pool_get_index(&rxe->mr_pool, key >> 8);
   526		if (!mr) {
                    ^^^
Quoted 8 lines

"mr" is NULL.

   527			rxe_dbg_mr(mr, "No MR for key %#x\n", key);
                                   ^^

Dereference.

   528			ret = -EINVAL;
   529			goto err;

I fixed it with this:

From 70c06ea1b57344599230e63d8fe5892f41c94116 Mon Sep 17 00:00:00 2001
From: Jason Gunthorpe <[email protected]>
Date: Tue, 22 Nov 2022 15:37:39 -0400
Subject: [PATCH] RDMA/rxe: Do not NULL deref on debugging failure path

Correct the mistake, mr is obviously NULL in this code path.

Fixes 2778b72b1df0 ("RDMA/rxe: Replace pr_xxx by rxe_dbg_xxx in rxe_mr.c")
---
 drivers/infiniband/sw/rxe/rxe_mr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_mr.c +1 -1
index b1423000e4bcda..b7c9ff1ddf0e14 100644
@@ -519,7 +519,7 @@ int rxe_invalidate_mr(struct rxe_qp *qp, u32 key)
 
 	mr = rxe_pool_get_index(&rxe->mr_pool, key >> 8);
 	if (!mr) {
-		rxe_dbg_mr(mr, "No MR for key %#x\n", key);
+		rxe_dbg_qp(qp, "No MR for key %#x\n", key);
 		ret = -EINVAL;
 		goto err;
 	}
Signature · 1 line
2.38.1