RDMA/hns: Fix uninitialized variable bug
Subsystems (2)
PATCH v2 1/1 RDMA/hns: Fix uninitialized variable bug
There is a potential execution path in which variable *ret* is returned without being properly initialized, previously.
Fix this by initializing variable *ret* to 0.
Addresses-Coverity-ID: 1491917 ("Uninitialized scalar variable")
---
Changes in v2:
- Set ret to 0 instead of -ENODEV. Thanks Weihang Li, for the feedback.
drivers/infiniband/hw/hns/hns_roce_hem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hem.c +1 -1
@@ -603,7 +603,7 @@ static int set_mhop_hem(struct hns_roce_dev *hr_dev, {struct ib_device *ibdev = &hr_dev->ib_dev;int step_idx; -int ret; +int ret =0 ;if (index->inited &HEM_INDEX_L0 ) { ret = hr_dev->hw->set_hem (hr_dev, table, obj,0 );
Signature · 1 line
2.26.0
Quoted 21 lines · Gustavo A. R. Silva
There is a potential execution path in which variable *ret* is returned without being properly initialized, previously.
Fix this by initializing variable *ret* to 0.
Addresses-Coverity-ID: 1491917 ("Uninitialized scalar variable")
Fixes 2f49de21f3e9 ("RDMA/hns: Optimize mhop get flow for multi-hop addressing")Signed-off-by Gustavo A. R. Silva <[email protected]>---
Changes in v2:
- Set ret to 0 instead of-ENODEV. Thanks Weihang Li, for the feedback.drivers/infiniband/hw/hns/hns_roce_hem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/infiniband/hw/hns/hns_roce_hem.c +0
-0
drivers/infiniband/hw/hns/hns_roce_hem.c static int set_mhop_hem(struct hns_roce_dev *hr_dev, · line 609
Quoted 8 lines
drivers/infiniband/hw/hns/hns_roce_hem.c +1
-1@@ -603,7 +603,7 @@ static int set_mhop_hem(struct hns_roce_dev *hr_dev, {struct ib_device *ibdev = &hr_dev->ib_dev;int step_idx; -int ret; +int ret =0 ;if (index->inited &HEM_INDEX_L0 ) { ret = hr_dev->hw->set_hem (hr_dev, table, obj,0 );
Jason Gunthorpe
AppliedQuoted 9 lines · Gustavo A. R. Silva
There is a potential execution path in which variable *ret* is returned without being properly initialized, previously.
Fix this by initializing variable *ret* to 0.
Addresses-Coverity-ID: 1491917 ("Uninitialized scalar variable")
Fixes 2f49de21f3e9 ("RDMA/hns: Optimize mhop get flow for multi-hop addressing")Signed-off-by Gustavo A. R. Silva <[email protected]>Acked-by Weihang Li <[email protected]>
Quoted 6 lines
---
Changes in v2:
- Set ret to 0 instead of-ENODEV. Thanks Weihang Li, for the feedback.drivers/infiniband/hw/hns/hns_roce_hem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to for-next, thanks
Jason