2022-12-10 11:42:44

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH v2 1/2] video: fbdev: uvesafb: Fixes an error handling path in uvesafb_probe()

If an error occurs after a successful uvesafb_init_mtrr() call, it must be
undone by a corresponding arch_phys_wc_del() call, as already done in the
remove function.

This has been added in the remove function in commit 63e28a7a5ffc
("uvesafb: Clean up MTRR code")

Fixes: 8bdb3a2d7df4 ("uvesafb: the driver core")
Signed-off-by: Christophe JAILLET <[email protected]>
---
Unsure about the Fixes tag, maybe it is 63e28a7a5ffc

Change in v2:
- add arch_phys_wc_del() at the right place in the error handling path

v1 (a long time ago!):
https://lore.kernel.org/all/dd2a4806d3a570ab84947806f38a494454fd0245.1622994310.git.christophe.jaillet@wanadoo.fr/
---
drivers/video/fbdev/uvesafb.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
index 00d789b6c0fa..0e3cabbec4b4 100644
--- a/drivers/video/fbdev/uvesafb.c
+++ b/drivers/video/fbdev/uvesafb.c
@@ -1758,6 +1758,7 @@ static int uvesafb_probe(struct platform_device *dev)
out_unmap:
iounmap(info->screen_base);
out_mem:
+ arch_phys_wc_del(par->mtrr_handle);
release_mem_region(info->fix.smem_start, info->fix.smem_len);
out_reg:
release_region(0x3c0, 32);
--
2.34.1


2022-12-10 11:58:30

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH v2 2/2] video: fbdev: uvesafb: Simplify uvesafb_remove()

When the remove() function is called, we know that the probe() function has
successfully been executed. So 'info' is known to be not NULL.

Simplify the code accordingly.

Signed-off-by: Christophe JAILLET <[email protected]>
---
Change in v2:
- new patch
---
drivers/video/fbdev/uvesafb.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
index 0e3cabbec4b4..2bb95c35ab2a 100644
--- a/drivers/video/fbdev/uvesafb.c
+++ b/drivers/video/fbdev/uvesafb.c
@@ -1777,25 +1777,23 @@ static int uvesafb_probe(struct platform_device *dev)
static int uvesafb_remove(struct platform_device *dev)
{
struct fb_info *info = platform_get_drvdata(dev);
+ struct uvesafb_par *par = info->par;

- if (info) {
- struct uvesafb_par *par = info->par;
+ sysfs_remove_group(&dev->dev.kobj, &uvesafb_dev_attgrp);
+ unregister_framebuffer(info);
+ release_region(0x3c0, 32);
+ iounmap(info->screen_base);
+ arch_phys_wc_del(par->mtrr_handle);
+ release_mem_region(info->fix.smem_start, info->fix.smem_len);
+ fb_destroy_modedb(info->monspecs.modedb);
+ fb_dealloc_cmap(&info->cmap);

- sysfs_remove_group(&dev->dev.kobj, &uvesafb_dev_attgrp);
- unregister_framebuffer(info);
- release_region(0x3c0, 32);
- iounmap(info->screen_base);
- arch_phys_wc_del(par->mtrr_handle);
- release_mem_region(info->fix.smem_start, info->fix.smem_len);
- fb_destroy_modedb(info->monspecs.modedb);
- fb_dealloc_cmap(&info->cmap);
+ kfree(par->vbe_modes);
+ kfree(par->vbe_state_orig);
+ kfree(par->vbe_state_saved);

- kfree(par->vbe_modes);
- kfree(par->vbe_state_orig);
- kfree(par->vbe_state_saved);
+ framebuffer_release(info);

- framebuffer_release(info);
- }
return 0;
}

--
2.34.1

2022-12-10 16:30:16

by Helge Deller

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] video: fbdev: uvesafb: Fixes an error handling path in uvesafb_probe()

On 12/10/22 12:35, Christophe JAILLET wrote:
> If an error occurs after a successful uvesafb_init_mtrr() call, it must be
> undone by a corresponding arch_phys_wc_del() call, as already done in the
> remove function.
>
> This has been added in the remove function in commit 63e28a7a5ffc
> ("uvesafb: Clean up MTRR code")
>
> Fixes: 8bdb3a2d7df4 ("uvesafb: the driver core")
> Signed-off-by: Christophe JAILLET <[email protected]>

Both patches applied.
Thanks!
Helge


> ---
> Unsure about the Fixes tag, maybe it is 63e28a7a5ffc
>
> Change in v2:
> - add arch_phys_wc_del() at the right place in the error handling path
>
> v1 (a long time ago!):
> https://lore.kernel.org/all/dd2a4806d3a570ab84947806f38a494454fd0245.1622994310.git.christophe.jaillet@wanadoo.fr/
> ---
> drivers/video/fbdev/uvesafb.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c
> index 00d789b6c0fa..0e3cabbec4b4 100644
> --- a/drivers/video/fbdev/uvesafb.c
> +++ b/drivers/video/fbdev/uvesafb.c
> @@ -1758,6 +1758,7 @@ static int uvesafb_probe(struct platform_device *dev)
> out_unmap:
> iounmap(info->screen_base);
> out_mem:
> + arch_phys_wc_del(par->mtrr_handle);
> release_mem_region(info->fix.smem_start, info->fix.smem_len);
> out_reg:
> release_region(0x3c0, 32);