[PATCH] fbdev: sstfb: use managed PCI device enable

Myeonghun Pak posted 1 patch 2 weeks ago
drivers/video/fbdev/sstfb.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] fbdev: sstfb: use managed PCI device enable
Posted by Myeonghun Pak 2 weeks ago
sstfb_probe() enables the PCI device with pci_enable_device(), but
failure paths after that point return without disabling it. The successful
probe path has the same imbalance because sstfb_remove() releases the
framebuffer, mappings and memory regions, but never calls
pci_disable_device().

Use pcim_enable_device() so the PCI core disables the device automatically
after probe failure or driver removal. The driver still releases its
framebuffer, mappings and memory regions explicitly.

This issue was identified during our ongoing static-analysis research while
reviewing kernel code.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
 drivers/video/fbdev/sstfb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/sstfb.c b/drivers/video/fbdev/sstfb.c
index 2ea947f57efb..0496b9d5ecc4 100644
--- a/drivers/video/fbdev/sstfb.c
+++ b/drivers/video/fbdev/sstfb.c
@@ -1332,7 +1332,8 @@ static int sstfb_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		return err;
 
 	/* Enable device in PCI config. */
-	if ((err=pci_enable_device(pdev))) {
+	err = pcim_enable_device(pdev);
+	if (err) {
 		printk(KERN_ERR "cannot enable device\n");
 		return err;
 	}
-- 
2.47.1
Re: [PATCH] fbdev: sstfb: use managed PCI device enable
Posted by Helge Deller 1 week, 5 days ago
On 9/11/26 02:08, Myeonghun Pak wrote:
> sstfb_probe() enables the PCI device with pci_enable_device(), but
> failure paths after that point return without disabling it. The successful
> probe path has the same imbalance because sstfb_remove() releases the
> framebuffer, mappings and memory regions, but never calls
> pci_disable_device().
> 
> Use pcim_enable_device() so the PCI core disables the device automatically
> after probe failure or driver removal. The driver still releases its
> framebuffer, mappings and memory regions explicitly.
> 
> This issue was identified during our ongoing static-analysis research while
> reviewing kernel code.
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
> ---
>   drivers/video/fbdev/sstfb.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
applied.

Thanks!
Helge