diff mbox series

[v2,next] RDMA/hns: Fix uninitialized variable bug

Message ID 20200328023539.GA32016@embeddedor (mailing list archive)
State Mainlined
Commit d35dc58dd26e2aef5dd7ed1929179c9974f8bb97
Delegated to: Jason Gunthorpe
Headers show
Series [v2,next] RDMA/hns: Fix uninitialized variable bug | expand

Commit Message

Gustavo A. R. Silva March 28, 2020, 2:35 a.m. UTC
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 <gustavo@embeddedor.com>
---
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(-)

Comments

Weihang Li March 28, 2020, 3:02 a.m. UTC | #1
On 2020/3/28 10:32, Gustavo A. R. Silva wrote:
> 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 <gustavo@embeddedor.com>
> ---
> 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(-)
> 
> diff --git a/drivers/infiniband/hw/hns/hns_roce_hem.c b/drivers/infiniband/hw/hns/hns_roce_hem.c
> index c96378718f88..263338b90d7a 100644
> --- a/drivers/infiniband/hw/hns/hns_roce_hem.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_hem.c
> @@ -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);
> 

Acked-by: Weihang Li <liweihang@huawei.com>
Jason Gunthorpe March 29, 2020, 2:10 p.m. UTC | #2
On Fri, Mar 27, 2020 at 09:35:39PM -0500, Gustavo A. R. Silva wrote:
> 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 <gustavo@embeddedor.com>
> Acked-by: Weihang Li <liweihang@huawei.com>
> ---
> 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
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/hns/hns_roce_hem.c b/drivers/infiniband/hw/hns/hns_roce_hem.c
index c96378718f88..263338b90d7a 100644
--- a/drivers/infiniband/hw/hns/hns_roce_hem.c
+++ b/drivers/infiniband/hw/hns/hns_roce_hem.c
@@ -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);