Add the missing platform_device_put() before return from
sysfb_create_simplefb() in the error handling case.
Fixes: 8633ef8 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")
Signed-off-by: Miaoqian Lin <[email protected]>
---
drivers/firmware/sysfb_simplefb.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/sysfb_simplefb.c b/drivers/firmware/sysfb_simplefb.c
index b86761904949..303a491e520d 100644
--- a/drivers/firmware/sysfb_simplefb.c
+++ b/drivers/firmware/sysfb_simplefb.c
@@ -113,12 +113,16 @@ __init int sysfb_create_simplefb(const struct screen_info *si,
sysfb_apply_efi_quirks(pd);
ret = platform_device_add_resources(pd, &res, 1);
- if (ret)
+ if (ret) {
+ platform_device_put(pd);
return ret;
+ }
ret = platform_device_add_data(pd, mode, sizeof(*mode));
- if (ret)
+ if (ret) {
+ platform_device_put(pd);
return ret;
+ }
return platform_device_add(pd);
}
--
2.17.1
Hello Miaoqian,
On 12/31/21 09:04, Miaoqian Lin wrote:
> Add the missing platform_device_put() before return from
> sysfb_create_simplefb() in the error handling case.
>
> Fixes: 8633ef8 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")
> Signed-off-by: Miaoqian Lin <[email protected]>
> ---
Thanks for the patch.
Reviewed-by: Javier Martinez Canillas <[email protected]>
> drivers/firmware/sysfb_simplefb.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/firmware/sysfb_simplefb.c b/drivers/firmware/sysfb_simplefb.c
> index b86761904949..303a491e520d 100644
> --- a/drivers/firmware/sysfb_simplefb.c
> +++ b/drivers/firmware/sysfb_simplefb.c
> @@ -113,12 +113,16 @@ __init int sysfb_create_simplefb(const struct screen_info *si,
> sysfb_apply_efi_quirks(pd);
>
> ret = platform_device_add_resources(pd, &res, 1);
> - if (ret)
> + if (ret) {
> + platform_device_put(pd);
> return ret;
> + }
>
> ret = platform_device_add_data(pd, mode, sizeof(*mode));
> - if (ret)
> + if (ret) {
> + platform_device_put(pd);
> return ret;
> + }
>
To avoid duplicating the error code logic twice, you could also do:
if (ret)
goto pdev_put;
> return platform_device_add(pd);
and then after this return statement:
pdev_put:
platform_device_put(pd);
return ret;
Best regards,
--
Javier Martinez Canillas
Linux Engineering
Red Hat
Add the missing platform_device_put() before return from
sysfb_create_simplefb() in the error handling case.
Fixes: 8633ef8 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")
Signed-off-by: Miaoqian Lin <[email protected]>
---
Changes in v2:
- Use goto label to avoid duplicating the error code logic.
---
drivers/firmware/sysfb_simplefb.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/sysfb_simplefb.c b/drivers/firmware/sysfb_simplefb.c
index b86761904949..46d776c29174 100644
--- a/drivers/firmware/sysfb_simplefb.c
+++ b/drivers/firmware/sysfb_simplefb.c
@@ -114,11 +114,15 @@ __init int sysfb_create_simplefb(const struct screen_info *si,
ret = platform_device_add_resources(pd, &res, 1);
if (ret)
- return ret;
+ goto pdev_put;
ret = platform_device_add_data(pd, mode, sizeof(*mode));
if (ret)
- return ret;
+ goto pdev_put;
return platform_device_add(pd);
+
+pdev_put:
+ platform_device_put(pd);
+ return ret;
}
--
2.17.1
On 1/16/22 13:16, Miaoqian Lin wrote:
> Add the missing platform_device_put() before return from
> sysfb_create_simplefb() in the error handling case.
>
> Fixes: 8633ef8 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")
> Signed-off-by: Miaoqian Lin <[email protected]>
> ---
> Changes in v2:
> - Use goto label to avoid duplicating the error code logic.
> ---
> drivers/firmware/sysfb_simplefb.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
Reviewed-by: Javier Martinez Canillas <[email protected]>
Best regards,
--
Javier Martinez Canillas
Linux Engineering
Red Hat
On Sun, Jan 16, 2022 at 06:31:09PM +0100, Javier Martinez Canillas wrote:
> On 1/16/22 13:16, Miaoqian Lin wrote:
> > Add the missing platform_device_put() before return from
> > sysfb_create_simplefb() in the error handling case.
> >
> > Fixes: 8633ef8 ("drivers/firmware: consolidate EFI framebuffer setup for all arches")
> > Signed-off-by: Miaoqian Lin <[email protected]>
> > ---
> > Changes in v2:
> > - Use goto label to avoid duplicating the error code logic.
> > ---
> > drivers/firmware/sysfb_simplefb.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> >
>
> Reviewed-by: Javier Martinez Canillas <[email protected]>
Does not apply to my tree :(