Skip to content

Commit

Permalink
fbdev: efifb: Register sysfs groups through driver core
Browse files Browse the repository at this point in the history
[ 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>
  • Loading branch information
t-8ch authored and gregkh committed Oct 10, 2024
1 parent 4b101d2 commit 36bfefb
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions drivers/video/fbdev/efifb.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,15 +571,10 @@ static int efifb_probe(struct platform_device *dev)
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);
if (err < 0) {
pr_err("efifb: cannot allocate colormap\n");
goto err_groups;
goto err_unmap;
}

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

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

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

static struct platform_driver efifb_driver = {
.driver = {
.name = "efi-framebuffer",
.dev_groups = efifb_groups,
},
.probe = efifb_probe,
.remove_new = efifb_remove,
Expand Down

0 comments on commit 36bfefb

Please sign in to comment.