Skip to contentSkip to conversation

RDMA/hns: Fix uninitialized return value in ret

PATCH New Colin King 1 participant 1 message Feb 24, 2021

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 RDMA/hns: Fix uninitialized return value in ret

From: Colin Ian King <[email protected]>

Currently if !r->hopnum is true in the for-loop and later on mapped_cnt < page_cnt is false we end up with an uninitialized value in ret being returned at the end of the function hns_roce_mtr_map. Fix this by keeping the original intent and ensure ret is zero by initializing ret at the start of the function.

Addresses-Coverity: ("Uninitialized scalar variable")

Fixes 9ea9a53ea93b ("RDMA/hns: Add mapped page count checking for MTR")
---
 drivers/infiniband/hw/hns/hns_roce_mr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_mr.c +1 -1
index 79b3c3023fe7..b8454dcb0318 100644
@@ -776,7 +776,7 @@ int hns_roce_mtr_map(struct hns_roce_dev *hr_dev, struct hns_roce_mtr *mtr,
 	struct ib_device *ibdev = &hr_dev->ib_dev;
 	struct hns_roce_buf_region *r;
 	unsigned int i, mapped_cnt;
-	int ret;
+	int ret = 0;
 
 	/*
 	 * Only use the first page address as root ba when hopnum is 0, this
Signature · 1 line
2.30.0