2018-06-11 17:35:45

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH] fpga: altera-cvp: Fix an error handling path in 'altera_cvp_probe()'

If 'fpga_mgr_create()' fails, we should release some resources, as done
in the other error handling path of the function.

Fixes: 7085e2a94f7d ("fpga: manager: change api, don't use drvdata")
Signed-off-by: Christophe JAILLET <[email protected]>
---
drivers/fpga/altera-cvp.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c
index dd4edd8f22ce..7fa793672a7a 100644
--- a/drivers/fpga/altera-cvp.c
+++ b/drivers/fpga/altera-cvp.c
@@ -455,8 +455,10 @@ static int altera_cvp_probe(struct pci_dev *pdev,

mgr = fpga_mgr_create(&pdev->dev, conf->mgr_name,
&altera_cvp_ops, conf);
- if (!mgr)
- return -ENOMEM;
+ if (!mgr) {
+ ret = -ENOMEM;
+ goto err_unmap;
+ }

pci_set_drvdata(pdev, mgr);

--
2.17.0



2018-06-13 12:44:07

by Moritz Fischer

[permalink] [raw]
Subject: Re: [PATCH] fpga: altera-cvp: Fix an error handling path in 'altera_cvp_probe()'

Hi Christophe,

good catch!

On Mon, Jun 11, 2018 at 12:20 PM, Christophe JAILLET
<[email protected]> wrote:
> If 'fpga_mgr_create()' fails, we should release some resources, as done
> in the other error handling path of the function.
>
> Fixes: 7085e2a94f7d ("fpga: manager: change api, don't use drvdata")
> Signed-off-by: Christophe JAILLET <[email protected]>
Reviewed-by: Moritz Fischer <[email protected]>
> ---
> drivers/fpga/altera-cvp.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c
> index dd4edd8f22ce..7fa793672a7a 100644
> --- a/drivers/fpga/altera-cvp.c
> +++ b/drivers/fpga/altera-cvp.c
> @@ -455,8 +455,10 @@ static int altera_cvp_probe(struct pci_dev *pdev,
>
> mgr = fpga_mgr_create(&pdev->dev, conf->mgr_name,
> &altera_cvp_ops, conf);
> - if (!mgr)
> - return -ENOMEM;
> + if (!mgr) {
> + ret = -ENOMEM;
> + goto err_unmap;
> + }
>
> pci_set_drvdata(pdev, mgr);
>
> --
> 2.17.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

Thanks,

Moritz

2018-06-13 14:29:53

by Alan Tull

[permalink] [raw]
Subject: Re: [PATCH] fpga: altera-cvp: Fix an error handling path in 'altera_cvp_probe()'

On Wed, Jun 13, 2018 at 7:42 AM, Moritz Fischer
<[email protected]> wrote:
> Hi Christophe,
>
> good catch!

Yes, thanks!

>
> On Mon, Jun 11, 2018 at 12:20 PM, Christophe JAILLET
> <[email protected]> wrote:
>> If 'fpga_mgr_create()' fails, we should release some resources, as done
>> in the other error handling path of the function.
>>
>> Fixes: 7085e2a94f7d ("fpga: manager: change api, don't use drvdata")
>> Signed-off-by: Christophe JAILLET <[email protected]>
> Reviewed-by: Moritz Fischer <[email protected]>
Acked-by: Alan Tull <[email protected]>

>> ---
>> drivers/fpga/altera-cvp.c | 6 ++++--
>> 1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c
>> index dd4edd8f22ce..7fa793672a7a 100644
>> --- a/drivers/fpga/altera-cvp.c
>> +++ b/drivers/fpga/altera-cvp.c
>> @@ -455,8 +455,10 @@ static int altera_cvp_probe(struct pci_dev *pdev,
>>
>> mgr = fpga_mgr_create(&pdev->dev, conf->mgr_name,
>> &altera_cvp_ops, conf);
>> - if (!mgr)
>> - return -ENOMEM;
>> + if (!mgr) {
>> + ret = -ENOMEM;
>> + goto err_unmap;
>> + }
>>
>> pci_set_drvdata(pdev, mgr);
>>
>> --
>> 2.17.0
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
>> the body of a message to [email protected]
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
> Thanks,
>
> Moritz