kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfio/fsl-mc: fix the return of the uninitialized variable ret
@ 2020-10-15 12:22 Colin King
  2020-10-15 18:52 ` Alex Williamson
  0 siblings, 1 reply; 4+ messages in thread
From: Colin King @ 2020-10-15 12:22 UTC (permalink / raw)
  To: Diana Craciun, Alex Williamson, Cornelia Huck, Eric Auger, kvm
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently the success path in function vfio_fsl_mc_reflck_attach is
returning an uninitialized value in variable ret. Fix this by setting
this to zero to indicate success.

Addresses-Coverity: ("Uninitialized scalar variable")
Fixes: f2ba7e8c947b ("vfio/fsl-mc: Added lock support in preparation for interrupt handling")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/vfio/fsl-mc/vfio_fsl_mc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
index 80fc7f4ed343..42a5decb78d1 100644
--- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
+++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
@@ -84,6 +84,7 @@ static int vfio_fsl_mc_reflck_attach(struct vfio_fsl_mc_device *vdev)
 		vfio_fsl_mc_reflck_get(cont_vdev->reflck);
 		vdev->reflck = cont_vdev->reflck;
 		vfio_device_put(device);
+		ret = 0;
 	}
 
 unlock:
-- 
2.27.0


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

* Re: [PATCH] vfio/fsl-mc: fix the return of the uninitialized variable ret
  2020-10-15 12:22 [PATCH] vfio/fsl-mc: fix the return of the uninitialized variable ret Colin King
@ 2020-10-15 18:52 ` Alex Williamson
  2020-10-16  9:26   ` Diana Craciun OSS
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Williamson @ 2020-10-15 18:52 UTC (permalink / raw)
  To: Colin King
  Cc: Diana Craciun, Cornelia Huck, Eric Auger, kvm, kernel-janitors,
	linux-kernel

On Thu, 15 Oct 2020 13:22:26 +0100
Colin King <colin.king@canonical.com> wrote:

> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently the success path in function vfio_fsl_mc_reflck_attach is
> returning an uninitialized value in variable ret. Fix this by setting
> this to zero to indicate success.
> 
> Addresses-Coverity: ("Uninitialized scalar variable")
> Fixes: f2ba7e8c947b ("vfio/fsl-mc: Added lock support in preparation for interrupt handling")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/vfio/fsl-mc/vfio_fsl_mc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
> index 80fc7f4ed343..42a5decb78d1 100644
> --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
> +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
> @@ -84,6 +84,7 @@ static int vfio_fsl_mc_reflck_attach(struct vfio_fsl_mc_device *vdev)
>  		vfio_fsl_mc_reflck_get(cont_vdev->reflck);
>  		vdev->reflck = cont_vdev->reflck;
>  		vfio_device_put(device);
> +		ret = 0;
>  	}
>  
>  unlock:

Looks correct to me, unless Diana would rather set the initial value to
zero instead.  Thanks,

Alex


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

* Re: [PATCH] vfio/fsl-mc: fix the return of the uninitialized variable ret
  2020-10-15 18:52 ` Alex Williamson
@ 2020-10-16  9:26   ` Diana Craciun OSS
  2020-10-16  9:49     ` Colin Ian King
  0 siblings, 1 reply; 4+ messages in thread
From: Diana Craciun OSS @ 2020-10-16  9:26 UTC (permalink / raw)
  To: Alex Williamson, Colin King
  Cc: Cornelia Huck, Eric Auger, kvm, kernel-janitors, linux-kernel

On 10/15/2020 9:52 PM, Alex Williamson wrote:
> On Thu, 15 Oct 2020 13:22:26 +0100
> Colin King <colin.king@canonical.com> wrote:
> 
>> From: Colin Ian King <colin.king@canonical.com>
>>
>> Currently the success path in function vfio_fsl_mc_reflck_attach is
>> returning an uninitialized value in variable ret. Fix this by setting
>> this to zero to indicate success.
>>
>> Addresses-Coverity: ("Uninitialized scalar variable")
>> Fixes: f2ba7e8c947b ("vfio/fsl-mc: Added lock support in preparation for interrupt handling")
>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>> ---
>>   drivers/vfio/fsl-mc/vfio_fsl_mc.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
>> index 80fc7f4ed343..42a5decb78d1 100644
>> --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
>> +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
>> @@ -84,6 +84,7 @@ static int vfio_fsl_mc_reflck_attach(struct vfio_fsl_mc_device *vdev)
>>   		vfio_fsl_mc_reflck_get(cont_vdev->reflck);
>>   		vdev->reflck = cont_vdev->reflck;
>>   		vfio_device_put(device);
>> +		ret = 0;
>>   	}
>>   
>>   unlock:
> 
> Looks correct to me, unless Diana would rather set the initial value to
> zero instead.  Thanks,
> 
> Alex
> 


I prefer to initialize the variable to 0 when it's defined. I'll send a 
patch for it.

Thanks,
Diana

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

* Re: [PATCH] vfio/fsl-mc: fix the return of the uninitialized variable ret
  2020-10-16  9:26   ` Diana Craciun OSS
@ 2020-10-16  9:49     ` Colin Ian King
  0 siblings, 0 replies; 4+ messages in thread
From: Colin Ian King @ 2020-10-16  9:49 UTC (permalink / raw)
  To: Diana Craciun OSS, Alex Williamson
  Cc: Cornelia Huck, Eric Auger, kvm, kernel-janitors, linux-kernel

On 16/10/2020 10:26, Diana Craciun OSS wrote:
> On 10/15/2020 9:52 PM, Alex Williamson wrote:
>> On Thu, 15 Oct 2020 13:22:26 +0100
>> Colin King <colin.king@canonical.com> wrote:
>>
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> Currently the success path in function vfio_fsl_mc_reflck_attach is
>>> returning an uninitialized value in variable ret. Fix this by setting
>>> this to zero to indicate success.
>>>
>>> Addresses-Coverity: ("Uninitialized scalar variable")
>>> Fixes: f2ba7e8c947b ("vfio/fsl-mc: Added lock support in preparation
>>> for interrupt handling")
>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
>>> ---
>>>   drivers/vfio/fsl-mc/vfio_fsl_mc.c | 1 +
>>>   1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
>>> b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
>>> index 80fc7f4ed343..42a5decb78d1 100644
>>> --- a/drivers/vfio/fsl-mc/vfio_fsl_mc.c
>>> +++ b/drivers/vfio/fsl-mc/vfio_fsl_mc.c
>>> @@ -84,6 +84,7 @@ static int vfio_fsl_mc_reflck_attach(struct
>>> vfio_fsl_mc_device *vdev)
>>>           vfio_fsl_mc_reflck_get(cont_vdev->reflck);
>>>           vdev->reflck = cont_vdev->reflck;
>>>           vfio_device_put(device);
>>> +        ret = 0;
>>>       }
>>>     unlock:
>>
>> Looks correct to me, unless Diana would rather set the initial value to
>> zero instead.  Thanks,
>>
>> Alex
>>
> 
> 
> I prefer to initialize the variable to 0 when it's defined. I'll send a
> patch for it.

Yep, works for me.

> 
> Thanks,
> Diana


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

end of thread, other threads:[~2020-10-16  9:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-15 12:22 [PATCH] vfio/fsl-mc: fix the return of the uninitialized variable ret Colin King
2020-10-15 18:52 ` Alex Williamson
2020-10-16  9:26   ` Diana Craciun OSS
2020-10-16  9:49     ` Colin Ian King

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).