mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
fbdev: efifb: Register sysfs groups through driver core
The driver core can register and cleanup sysfs groups already. Make use of that functionality to simplify the error handling and cleanup. Also avoid a UAF race during unregistering where the sysctl attributes were usable after the info struct was freed. Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Helge Deller <deller@gmx.de>
This commit is contained in:
parent
929c81ade6
commit
95cdd538e0
1 changed files with 2 additions and 9 deletions
|
@ -561,15 +561,10 @@ static int efifb_probe(struct platform_device *dev)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = sysfs_create_groups(&dev->dev.kobj, efifb_groups);
|
|
||||||
if (err) {
|
|
||||||
pr_err("efifb: cannot add sysfs attrs\n");
|
|
||||||
goto err_unmap;
|
|
||||||
}
|
|
||||||
err = fb_alloc_cmap(&info->cmap, 256, 0);
|
err = fb_alloc_cmap(&info->cmap, 256, 0);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
pr_err("efifb: cannot allocate colormap\n");
|
pr_err("efifb: cannot allocate colormap\n");
|
||||||
goto err_groups;
|
goto err_unmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = devm_aperture_acquire_for_platform_device(dev, par->base, par->size);
|
err = devm_aperture_acquire_for_platform_device(dev, par->base, par->size);
|
||||||
|
@ -587,8 +582,6 @@ static int efifb_probe(struct platform_device *dev)
|
||||||
|
|
||||||
err_fb_dealloc_cmap:
|
err_fb_dealloc_cmap:
|
||||||
fb_dealloc_cmap(&info->cmap);
|
fb_dealloc_cmap(&info->cmap);
|
||||||
err_groups:
|
|
||||||
sysfs_remove_groups(&dev->dev.kobj, efifb_groups);
|
|
||||||
err_unmap:
|
err_unmap:
|
||||||
if (mem_flags & (EFI_MEMORY_UC | EFI_MEMORY_WC))
|
if (mem_flags & (EFI_MEMORY_UC | EFI_MEMORY_WC))
|
||||||
iounmap(info->screen_base);
|
iounmap(info->screen_base);
|
||||||
|
@ -608,12 +601,12 @@ static void efifb_remove(struct platform_device *pdev)
|
||||||
|
|
||||||
/* efifb_destroy takes care of info cleanup */
|
/* efifb_destroy takes care of info cleanup */
|
||||||
unregister_framebuffer(info);
|
unregister_framebuffer(info);
|
||||||
sysfs_remove_groups(&pdev->dev.kobj, efifb_groups);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct platform_driver efifb_driver = {
|
static struct platform_driver efifb_driver = {
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "efi-framebuffer",
|
.name = "efi-framebuffer",
|
||||||
|
.dev_groups = efifb_groups,
|
||||||
},
|
},
|
||||||
.probe = efifb_probe,
|
.probe = efifb_probe,
|
||||||
.remove_new = efifb_remove,
|
.remove_new = efifb_remove,
|
||||||
|
|
Loading…
Add table
Reference in a new issue