linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] RDMA/hns: Fix uninitialized variable bug
@ 2020-03-27 19:31 Gustavo A. R. Silva
  2020-03-28  2:15 ` liweihang
  0 siblings, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2020-03-27 19:31 UTC (permalink / raw)
  To: Lijun Ou, Wei Hu(Xavier),
	Weihang Li, Doug Ledford, Jason Gunthorpe, Xi Wang
  Cc: linux-rdma, linux-kernel, 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 -ENODEV.

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>
---
 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..3fd8100c2b56 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 = -ENODEV;
 
 	if (index->inited & HEM_INDEX_L0) {
 		ret = hr_dev->hw->set_hem(hr_dev, table, obj, 0);
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH][next] RDMA/hns: Fix uninitialized variable bug
  2020-03-27 19:31 [PATCH][next] RDMA/hns: Fix uninitialized variable bug Gustavo A. R. Silva
@ 2020-03-28  2:15 ` liweihang
  2020-03-28  2:28   ` Gustavo A. R. Silva
  2020-03-28 12:40   ` Jason Gunthorpe
  0 siblings, 2 replies; 4+ messages in thread
From: liweihang @ 2020-03-28  2:15 UTC (permalink / raw)
  To: Gustavo A. R. Silva, oulijun, Huwei (Xavier),
	Doug Ledford, Jason Gunthorpe, wangxi (M)
  Cc: linux-rdma, linux-kernel

On 2020/3/28 3:28, 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 -ENODEV.
> 
> 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>
> ---
>  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..3fd8100c2b56 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 = -ENODEV;
>  
>  	if (index->inited & HEM_INDEX_L0) {
>  		ret = hr_dev->hw->set_hem(hr_dev, table, obj, 0);
> 

Hi Gustavo,

Thanks for your modification. But I check the code and I think "ret"
should be initialized to 0, which means no need to set hem and it is
not an error.

Weihang

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][next] RDMA/hns: Fix uninitialized variable bug
  2020-03-28  2:15 ` liweihang
@ 2020-03-28  2:28   ` Gustavo A. R. Silva
  2020-03-28 12:40   ` Jason Gunthorpe
  1 sibling, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2020-03-28  2:28 UTC (permalink / raw)
  To: liweihang, oulijun, Huwei (Xavier),
	Doug Ledford, Jason Gunthorpe, wangxi (M)
  Cc: linux-rdma, linux-kernel



On 3/27/20 21:15, liweihang wrote:
> On 2020/3/28 3:28, 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 -ENODEV.
>>
>> 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>
>> ---
>>  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..3fd8100c2b56 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 = -ENODEV;
>>  
>>  	if (index->inited & HEM_INDEX_L0) {
>>  		ret = hr_dev->hw->set_hem(hr_dev, table, obj, 0);
>>
> 
> Hi Gustavo,
> 

Hi Weihang,

> Thanks for your modification. But I check the code and I think "ret"
> should be initialized to 0, which means no need to set hem and it is
> not an error.
> 

Oh, I see. Thanks for the feedback. I'll send v2 shortly.

Thanks
--
Gustavo

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH][next] RDMA/hns: Fix uninitialized variable bug
  2020-03-28  2:15 ` liweihang
  2020-03-28  2:28   ` Gustavo A. R. Silva
@ 2020-03-28 12:40   ` Jason Gunthorpe
  1 sibling, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2020-03-28 12:40 UTC (permalink / raw)
  To: liweihang
  Cc: Gustavo A. R. Silva, oulijun, Huwei (Xavier),
	Doug Ledford, wangxi (M),
	linux-rdma, linux-kernel

On Sat, Mar 28, 2020 at 02:15:14AM +0000, liweihang wrote:
> On 2020/3/28 3:28, 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 -ENODEV.
> > 
> > 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>
> >  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..3fd8100c2b56 100644
> > +++ 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 = -ENODEV;
> >  
> >  	if (index->inited & HEM_INDEX_L0) {
> >  		ret = hr_dev->hw->set_hem(hr_dev, table, obj, 0);
> > 
> 
> Hi Gustavo,
> 
> Thanks for your modification. But I check the code and I think "ret"
> should be initialized to 0, which means no need to set hem and it is
> not an error.

Weihang, thank you for checking, I would have taken it without your remarks :)

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-03-28 12:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-27 19:31 [PATCH][next] RDMA/hns: Fix uninitialized variable bug Gustavo A. R. Silva
2020-03-28  2:15 ` liweihang
2020-03-28  2:28   ` Gustavo A. R. Silva
2020-03-28 12:40   ` Jason Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).