2023-01-16 15:47:31

by Maksim Davydov

[permalink] [raw]
Subject: [PATCH net 2/2] net/ethernet/chelsio: t4_handle_fw_rpl fix NULL

After t4_hw.c:t4_prep_adapter() that is called in cxgb4_main.c:init_one()
adapter has it least 1 port for debug. Thus, for_each_port() usually has
at least 1 iteration, but this function can be called with wrong
configured adapter

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Fixes: 23853a0a9a76 ("cxgb4: Don't assume FW_PORT_CMD reply is always
port info msg")

Signed-off-by: Maksim Davydov <[email protected]>
---
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index 8d719f82854a..2f7b49473f52 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -8864,7 +8864,8 @@ int t4_handle_fw_rpl(struct adapter *adap, const __be64 *rpl)
break;
}

- t4_handle_get_port_info(pi, rpl);
+ if (pi)
+ t4_handle_get_port_info(pi, rpl);
} else {
dev_warn(adap->pdev_dev, "Unknown firmware reply %d\n",
opcode);
--
2.25.1


2023-01-17 11:58:32

by Leon Romanovsky

[permalink] [raw]
Subject: Re: [PATCH net 2/2] net/ethernet/chelsio: t4_handle_fw_rpl fix NULL

On Mon, Jan 16, 2023 at 06:21:00PM +0300, Maksim Davydov wrote:
> After t4_hw.c:t4_prep_adapter() that is called in cxgb4_main.c:init_one()
> adapter has it least 1 port for debug.

IMHO it is wrong to keep this interface and the logic for this debug
code should be deleted.

Thanks