Skip to content

Commit 36bfefb

Browse files
t-8chgregkh
authored andcommitted
fbdev: efifb: Register sysfs groups through driver core
[ Upstream commit 95cdd53 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 4b101d2 commit 36bfefb

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

drivers/video/fbdev/efifb.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -571,15 +571,10 @@ static int efifb_probe(struct platform_device *dev)
571571
break;
572572
}
573573

574-
err = sysfs_create_groups(&dev->dev.kobj, efifb_groups);
575-
if (err) {
576-
pr_err("efifb: cannot add sysfs attrs\n");
577-
goto err_unmap;
578-
}
579574
err = fb_alloc_cmap(&info->cmap, 256, 0);
580575
if (err < 0) {
581576
pr_err("efifb: cannot allocate colormap\n");
582-
goto err_groups;
577+
goto err_unmap;
583578
}
584579

585580
if (efifb_pci_dev)
@@ -603,8 +598,6 @@ static int efifb_probe(struct platform_device *dev)
603598
pm_runtime_put(&efifb_pci_dev->dev);
604599

605600
fb_dealloc_cmap(&info->cmap);
606-
err_groups:
607-
sysfs_remove_groups(&dev->dev.kobj, efifb_groups);
608601
err_unmap:
609602
if (mem_flags & (EFI_MEMORY_UC | EFI_MEMORY_WC))
610603
iounmap(info->screen_base);
@@ -624,12 +617,12 @@ static void efifb_remove(struct platform_device *pdev)
624617

625618
/* efifb_destroy takes care of info cleanup */
626619
unregister_framebuffer(info);
627-
sysfs_remove_groups(&pdev->dev.kobj, efifb_groups);
628620
}
629621

630622
static struct platform_driver efifb_driver = {
631623
.driver = {
632624
.name = "efi-framebuffer",
625+
.dev_groups = efifb_groups,
633626
},
634627
.probe = efifb_probe,
635628
.remove_new = efifb_remove,

0 commit comments

Comments
 (0)