RDMA/bng_re: fix variable dereferenced before check in bng_re_net_ring_free()
Subsystems (2)
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
@@ -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
Siva Reddy Kallam
maintainerQuoted 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:113bng_re_net_ring_free()warn:
variable dereferenced before check 'rdev'Reported-by kernel test robot <[email protected]>Reported-by Dan Carpenter <[email protected]>Signed-off-by sunliming <[email protected]>--- 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@@ -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
-1if (!aux_dev)return rc; --2.25.1