Skip to content

Commit 95cdd53

Browse files
t-8chhdeller
authored andcommitted
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 <[email protected]> Signed-off-by: Helge Deller <[email protected]>
1 parent 929c81a commit 95cdd53

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
@@ -561,15 +561,10 @@ static int efifb_probe(struct platform_device *dev)
561561
break;
562562
}
563563

564-
err = sysfs_create_groups(&dev->dev.kobj, efifb_groups);
565-
if (err) {
566-
pr_err("efifb: cannot add sysfs attrs\n");
567-
goto err_unmap;
568-
}
569564
err = fb_alloc_cmap(&info->cmap, 256, 0);
570565
if (err < 0) {
571566
pr_err("efifb: cannot allocate colormap\n");
572-
goto err_groups;
567+
goto err_unmap;
573568
}
574569

575570
err = devm_aperture_acquire_for_platform_device(dev, par->base, par->size);
@@ -587,8 +582,6 @@ static int efifb_probe(struct platform_device *dev)
587582

588583
err_fb_dealloc_cmap:
589584
fb_dealloc_cmap(&info->cmap);
590-
err_groups:
591-
sysfs_remove_groups(&dev->dev.kobj, efifb_groups);
592585
err_unmap:
593586
if (mem_flags & (EFI_MEMORY_UC | EFI_MEMORY_WC))
594587
iounmap(info->screen_base);
@@ -608,12 +601,12 @@ static void efifb_remove(struct platform_device *pdev)
608601

609602
/* efifb_destroy takes care of info cleanup */
610603
unregister_framebuffer(info);
611-
sysfs_remove_groups(&pdev->dev.kobj, efifb_groups);
612604
}
613605

614606
static struct platform_driver efifb_driver = {
615607
.driver = {
616608
.name = "efi-framebuffer",
609+
.dev_groups = efifb_groups,
617610
},
618611
.probe = efifb_probe,
619612
.remove_new = efifb_remove,

0 commit comments

Comments
 (0)