kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] samples: vfio-mdev: fix error return code in mdpy_fb_probe()
@ 2021-05-19 14:15 Wei Yongjun
  2021-05-19 15:45 ` Alex Williamson
  0 siblings, 1 reply; 5+ messages in thread
From: Wei Yongjun @ 2021-05-19 14:15 UTC (permalink / raw)
  To: weiyongjun1, Kirti Wankhede; +Cc: kvm, kernel-janitors, Hulk Robot

Fix to return negative error code -ENOMEM from the error handling
case instead of 0, as done elsewhere in this function.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 samples/vfio-mdev/mdpy-fb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/samples/vfio-mdev/mdpy-fb.c b/samples/vfio-mdev/mdpy-fb.c
index 21dbf63d6e41..d4abc0594dbd 100644
--- a/samples/vfio-mdev/mdpy-fb.c
+++ b/samples/vfio-mdev/mdpy-fb.c
@@ -131,8 +131,10 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
 		 width, height);
 
 	info = framebuffer_alloc(sizeof(struct mdpy_fb_par), &pdev->dev);
-	if (!info)
+	if (!info) {
+		ret = -ENOMEM;
 		goto err_release_regions;
+	}
 	pci_set_drvdata(pdev, info);
 	par = info->par;
 


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

* Re: [PATCH -next] samples: vfio-mdev: fix error return code in mdpy_fb_probe()
  2021-05-19 14:15 [PATCH -next] samples: vfio-mdev: fix error return code in mdpy_fb_probe() Wei Yongjun
@ 2021-05-19 15:45 ` Alex Williamson
  2021-05-20  5:25   ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Williamson @ 2021-05-19 15:45 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: Kirti Wankhede, kvm, kernel-janitors, Hulk Robot, kraxel

On Wed, 19 May 2021 14:15:59 +0000
Wei Yongjun <weiyongjun1@huawei.com> wrote:

> Fix to return negative error code -ENOMEM from the error handling
> case instead of 0, as done elsewhere in this function.
> 
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  samples/vfio-mdev/mdpy-fb.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/samples/vfio-mdev/mdpy-fb.c b/samples/vfio-mdev/mdpy-fb.c
> index 21dbf63d6e41..d4abc0594dbd 100644
> --- a/samples/vfio-mdev/mdpy-fb.c
> +++ b/samples/vfio-mdev/mdpy-fb.c
> @@ -131,8 +131,10 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
>  		 width, height);
>  
>  	info = framebuffer_alloc(sizeof(struct mdpy_fb_par), &pdev->dev);
> -	if (!info)
> +	if (!info) {
> +		ret = -ENOMEM;
>  		goto err_release_regions;
> +	}
>  	pci_set_drvdata(pdev, info);
>  	par = info->par;
>  
> 

I think there's also a question of why the three 'return -EINVAL;' exit
paths between here and the prior call to pci_request_regions() don't
also take this goto.  Thanks,

Alex


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

* Re: [PATCH -next] samples: vfio-mdev: fix error return code in mdpy_fb_probe()
  2021-05-19 15:45 ` Alex Williamson
@ 2021-05-20  5:25   ` Dan Carpenter
  2021-05-20  8:10     ` weiyongjun (A)
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2021-05-20  5:25 UTC (permalink / raw)
  To: Alex Williamson
  Cc: Wei Yongjun, Kirti Wankhede, kvm, kernel-janitors, Hulk Robot, kraxel

On Wed, May 19, 2021 at 09:45:12AM -0600, Alex Williamson wrote:
> On Wed, 19 May 2021 14:15:59 +0000
> Wei Yongjun <weiyongjun1@huawei.com> wrote:
> 
> > Fix to return negative error code -ENOMEM from the error handling
> > case instead of 0, as done elsewhere in this function.
> > 
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> > Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> > ---
> >  samples/vfio-mdev/mdpy-fb.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/samples/vfio-mdev/mdpy-fb.c b/samples/vfio-mdev/mdpy-fb.c
> > index 21dbf63d6e41..d4abc0594dbd 100644
> > --- a/samples/vfio-mdev/mdpy-fb.c
> > +++ b/samples/vfio-mdev/mdpy-fb.c
> > @@ -131,8 +131,10 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
> >  		 width, height);
> >  
> >  	info = framebuffer_alloc(sizeof(struct mdpy_fb_par), &pdev->dev);
> > -	if (!info)
> > +	if (!info) {
> > +		ret = -ENOMEM;
> >  		goto err_release_regions;
> > +	}
> >  	pci_set_drvdata(pdev, info);
> >  	par = info->par;
> >  
> > 
> 
> I think there's also a question of why the three 'return -EINVAL;' exit
> paths between here and the prior call to pci_request_regions() don't
> also take this goto.  Thanks,
> 

Smatch catches one of these leaks...  Which is weird that it would
ignore the other error paths.  Perhaps it was intentional?

samples/vfio-mdev/mdpy-fb.c:135 mdpy_fb_probe() warn: missing error code 'ret'
samples/vfio-mdev/mdpy-fb.c:189 mdpy_fb_probe() warn: 'pdev' not released on lines: 120.

regards,
dan carpenter

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

* Re: [PATCH -next] samples: vfio-mdev: fix error return code in mdpy_fb_probe()
  2021-05-20  5:25   ` Dan Carpenter
@ 2021-05-20  8:10     ` weiyongjun (A)
  0 siblings, 0 replies; 5+ messages in thread
From: weiyongjun (A) @ 2021-05-20  8:10 UTC (permalink / raw)
  To: Dan Carpenter, Alex Williamson
  Cc: Kirti Wankhede, kvm, kernel-janitors, Hulk Robot, kraxel


> On Wed, May 19, 2021 at 09:45:12AM -0600, Alex Williamson wrote:
>> On Wed, 19 May 2021 14:15:59 +0000
>> Wei Yongjun <weiyongjun1@huawei.com> wrote:
>>
>>> Fix to return negative error code -ENOMEM from the error handling
>>> case instead of 0, as done elsewhere in this function.
>>>
>>> Reported-by: Hulk Robot <hulkci@huawei.com>
>>> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
>>> ---
>>>   samples/vfio-mdev/mdpy-fb.c | 4 +++-
>>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/samples/vfio-mdev/mdpy-fb.c b/samples/vfio-mdev/mdpy-fb.c
>>> index 21dbf63d6e41..d4abc0594dbd 100644
>>> --- a/samples/vfio-mdev/mdpy-fb.c
>>> +++ b/samples/vfio-mdev/mdpy-fb.c
>>> @@ -131,8 +131,10 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
>>>   		 width, height);
>>>   
>>>   	info = framebuffer_alloc(sizeof(struct mdpy_fb_par), &pdev->dev);
>>> -	if (!info)
>>> +	if (!info) {
>>> +		ret = -ENOMEM;
>>>   		goto err_release_regions;
>>> +	}
>>>   	pci_set_drvdata(pdev, info);
>>>   	par = info->par;
>>>   
>>>
>> I think there's also a question of why the three 'return -EINVAL;' exit
>> paths between here and the prior call to pci_request_regions() don't
>> also take this goto.  Thanks,
>>
> Smatch catches one of these leaks...  Which is weird that it would
> ignore the other error paths.  Perhaps it was intentional?
>
> samples/vfio-mdev/mdpy-fb.c:135 mdpy_fb_probe() warn: missing error code 'ret'
> samples/vfio-mdev/mdpy-fb.c:189 mdpy_fb_probe() warn: 'pdev' not released on lines: 120.


The first one is found by coccinelle script, and I have no patterns
to catch the second one now. It seems that smatch is more clever with
this kind of issues.

Regards,

Wei Yongjun



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

* [PATCH -next] samples: vfio-mdev: fix error return code in mdpy_fb_probe()
@ 2020-04-27 14:21 Wei Yongjun
  0 siblings, 0 replies; 5+ messages in thread
From: Wei Yongjun @ 2020-04-27 14:21 UTC (permalink / raw)
  To: Kirti Wankhede; +Cc: Wei Yongjun, kvm, kernel-janitors

Fix to return negative error code -ENOMEM from the error handling
case instead of 0, as done elsewhere in this function.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 samples/vfio-mdev/mdpy-fb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/samples/vfio-mdev/mdpy-fb.c b/samples/vfio-mdev/mdpy-fb.c
index 21dbf63d6e41..d4abc0594dbd 100644
--- a/samples/vfio-mdev/mdpy-fb.c
+++ b/samples/vfio-mdev/mdpy-fb.c
@@ -131,8 +131,10 @@ static int mdpy_fb_probe(struct pci_dev *pdev,
 		 width, height);
 
 	info = framebuffer_alloc(sizeof(struct mdpy_fb_par), &pdev->dev);
-	if (!info)
+	if (!info) {
+		ret = -ENOMEM;
 		goto err_release_regions;
+	}
 	pci_set_drvdata(pdev, info);
 	par = info->par;




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

end of thread, other threads:[~2021-05-20  8:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19 14:15 [PATCH -next] samples: vfio-mdev: fix error return code in mdpy_fb_probe() Wei Yongjun
2021-05-19 15:45 ` Alex Williamson
2021-05-20  5:25   ` Dan Carpenter
2021-05-20  8:10     ` weiyongjun (A)
  -- strict thread matches above, loose matches on Subject: below --
2020-04-27 14:21 Wei Yongjun

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