net/xsc: fix uninitialized return value in QP modify
PATCH 1/1 net/xsc: fix uninitialized return value in QP modify
If xsc_vfio_modify_qp_status() is called with num <= 0 the loop is skipped and an uninitialized value is returned. All current callers pass num = 1, but gcc 15 at -O1 cannot see that through the dev_ops indirection and reports:
xsc_vfio.c:491:16: error: 'ret' may be used uninitialized
Initialize ret to 0.
Bugzilla ID: 2099
--- drivers/net/xsc/xsc_vfio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/xsc/xsc_vfio.c +1 -1
@@ -449,7 +449,7 @@ xsc_vfio_link_get(struct xsc_dev *xdev, struct rte_eth_link *link)static int xsc_vfio_modify_qp_status (struct xsc_dev *xdev,uint32_t qpn,int num,int opcode) { -int i, ret; +int i, ret =0 ;int in_len, out_len, cmd_len;struct xsc_cmd_modify_qp_mbox_in *in;struct xsc_cmd_modify_qp_mbox_out *out;
Signature · 1 line
2.53.0
Quoted 23 lines · Stephen Hemminger
If
xsc_vfio_modify_qp_status()is called with num <= 0 the loop is skipped and an uninitialized value is returned. All current callers pass num = 1, but gcc 15 at -O1 cannot see that through thedev_opsindirection and reports:xsc_vfio.c:491:16: error: 'ret' may be used uninitialized
Initialize ret to 0.
Bugzilla ID: 2099
Fixes 31e84e37c0b9 ("net/xsc: support VFIO")Signed-off-by Stephen Hemminger <[email protected]>--- drivers/net/xsc/xsc_vfio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/xsc/xsc_vfio.c +0
-0
drivers/net/xsc/xsc_vfio.c xsc_vfio_link_get(struct xsc_dev *xdev, struct rte_eth_link *link) · line 455
Quoted 8 lines
drivers/net/xsc/xsc_vfio.c +1
-1@@ -449,7 +449,7 @@ xsc_vfio_link_get(struct xsc_dev *xdev, struct rte_eth_link *link)static int xsc_vfio_modify_qp_status (struct xsc_dev *xdev,uint32_t qpn,int num,int opcode) { -int i, ret; +int i, ret =0 ;int in_len, out_len, cmd_len;struct xsc_cmd_modify_qp_mbox_in *in;struct xsc_cmd_modify_qp_mbox_out *out;
Thanks for the fix, Stephen.