Skip to contentSkip to conversation

RDMA/bng_re: fix variable dereferenced before check in bng_re_net_ring_free()

PATCH In review [email protected] 2 participants 2 messages Jan 6

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

PATCH 1/1 RDMA/bng_re: fix variable dereferenced before check in bng_re_net_ring_free()

From: sunliming <[email protected]>

Fix below smatch warnings:
drivers/infiniband/hw/bng_re/bng_dev.c:113 bng_re_net_ring_free() warn:
variable dereferenced before check 'rdev'

---
 drivers/infiniband/hw/bng_re/bng_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/hw/bng_re/bng_dev.c +2 -1
index d8f8d7f7075f..c32395d1593f 100644
@@ -118,7 +118,7 @@ static void bng_re_fill_fw_msg(struct bnge_fw_msg *fw_msg, void *msg,
 static int bng_re_net_ring_free(struct bng_re_dev *rdev,
 				u16 fw_ring_id, int type)
 {
-	struct bnge_auxr_dev *aux_dev = rdev->aux_dev;
+	struct bnge_auxr_dev *aux_dev;
 	struct hwrm_ring_free_input req = {};
 	struct hwrm_ring_free_output resp;
 	struct bnge_fw_msg fw_msg = {};
@@ -127,6 +127,7 @@ static int bng_re_net_ring_free(struct bng_re_dev *rdev,
 	if (!rdev)
 		return rc;
 
+	aux_dev = rdev->aux_dev;
 	if (!aux_dev)
 		return rc;
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 29 lines · On Tue, Jan 6, 2026 at 5:34 PM <[email protected]> wrote:

From: sunliming <[email protected]>

Fix below smatch warnings:
drivers/infiniband/hw/bng_re/bng_dev.c:113 bng_re_net_ring_free() warn:
variable dereferenced before check 'rdev'

---
 drivers/infiniband/hw/bng_re/bng_dev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/hw/bng_re/bng_dev.c +1 -1
index d8f8d7f7075f..c32395d1593f 100644
@@ -118,7 +118,7 @@ static void bng_re_fill_fw_msg(struct bnge_fw_msg *fw_msg, void *msg,
 static int bng_re_net_ring_free(struct bng_re_dev *rdev,
                                u16 fw_ring_id, int type)
 {
-       struct bnge_auxr_dev *aux_dev = rdev->aux_dev;
+       struct bnge_auxr_dev *aux_dev;
        struct hwrm_ring_free_input req = {};
        struct hwrm_ring_free_output resp;
        struct bnge_fw_msg fw_msg = {};

drivers/infiniband/hw/bng_re/bng_dev.c static int bng_re_net_ring_free(struct bng_re_dev *rdev, · line 130

Quoted 4 lines
drivers/infiniband/hw/bng_re/bng_dev.c +1 -0
@@ -127,6 +127,7 @@ static int bng_re_net_ring_free(struct bng_re_dev *rdev,
        if (!rdev)
                return rc;
 
+       aux_dev = rdev->aux_dev;

rdev is valid from the caller. NULL check for rdev can be removed. I need to do few more changes for
addressing other comments in
https://lore.kernel.org/all/[email protected]/.
I will be pushing a patch soon along with removing if(!rdev). Thanks.

Quoted 6 lines
drivers/infiniband/hw/bng_re/bng_dev.c +0 -1
        if (!aux_dev)
                return rc;
 
--

2.25.1