All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: sm750fb: Unmap PCI resources on framebuffer probe failure
@ 2026-12-02  3:37 Haoxiang Li
  2026-12-02  7:39 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Haoxiang Li @ 2026-12-02  3:37 UTC (permalink / raw)
  To: sudipm.mukherjee, teddy.wang, gregkh
  Cc: linux-fbdev, linux-staging, Haoxiang Li

hw_sm750_map() allocates the PCI region and maps both the
registers and video memory, but not freed on probe failure,
causing a potential leak. Add a unmap helper and call it
on probe failure. Also call arch_phys_wc_del() as done in
lynxfb_pci_remove() and change the error label.

Fixes: 81dee67e215b ("staging: sm750fb: add sm750 to staging")
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
 drivers/staging/sm750fb/sm750.c    | 10 +++++-----
 drivers/staging/sm750fb/sm750.h    |  1 +
 drivers/staging/sm750fb/sm750_hw.c |  7 +++++++
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 6ce02ea48d2c..6e5c6de2fcfb 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -1024,13 +1024,15 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
 	for (fbidx = 0; fbidx < max_fb; fbidx++) {
 		err = sm750fb_framebuffer_alloc(sm750_dev, fbidx);
 		if (err)
-			goto release_fb;
+			goto release;
 	}
 
 	return 0;
 
-release_fb:
+release:
 	sm750fb_framebuffer_release(sm750_dev);
+	arch_phys_wc_del(sm750_dev->mtrr.vram);
+	hw_sm750_unmap(sm750_dev);
 	return err;
 }
 
@@ -1043,9 +1045,7 @@ static void lynxfb_pci_remove(struct pci_dev *pdev)
 	sm750fb_framebuffer_release(sm750_dev);
 	arch_phys_wc_del(sm750_dev->mtrr.vram);
 
-	iounmap(sm750_dev->mmio);
-	iounmap(sm750_dev->vmem);
-	pci_release_region(pdev, 1);
+	hw_sm750_unmap(sm750_dev);
 	kfree(g_settings);
 }
 
diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h
index fd1cf9eb5797..b7f33fbf2138 100644
--- a/drivers/staging/sm750fb/sm750.h
+++ b/drivers/staging/sm750fb/sm750.h
@@ -178,6 +178,7 @@ static inline unsigned long ps_to_hz(unsigned int psvalue)
 }
 
 int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev);
+void hw_sm750_unmap(struct sm750_dev *sm750_dev);
 int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev);
 void hw_sm750_init_accel(struct sm750_dev *sm750_dev);
 int hw_sm750_de_wait(void);
diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c
index c4358d3e5091..fd357527ba4c 100644
--- a/drivers/staging/sm750fb/sm750_hw.c
+++ b/drivers/staging/sm750fb/sm750_hw.c
@@ -64,6 +64,13 @@ int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
 	return ret;
 }
 
+void hw_sm750_unmap(struct sm750_dev *sm750_dev)
+{
+	iounmap(sm750_dev->vmem);
+	iounmap(sm750_dev->mmio);
+	pci_release_region(sm750_dev->pdev, 1);
+}
+
 int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
 {
 	struct initchip_param *parm;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: sm750fb: Unmap PCI resources on framebuffer probe failure
  2026-12-02  3:37 [PATCH] staging: sm750fb: Unmap PCI resources on framebuffer probe failure Haoxiang Li
@ 2026-12-02  7:39 ` Greg KH
  2026-12-02  7:58   ` Haoxiang Li
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2026-12-02  7:39 UTC (permalink / raw)
  To: Haoxiang Li; +Cc: sudipm.mukherjee, teddy.wang, linux-fbdev, linux-staging

On Wed, Dec 02, 2026 at 11:37:12AM +0800, Haoxiang Li wrote:
> hw_sm750_map() allocates the PCI region and maps both the
> registers and video memory, but not freed on probe failure,
> causing a potential leak. Add a unmap helper and call it
> on probe failure. Also call arch_phys_wc_del() as done in
> lynxfb_pci_remove() and change the error label.
> 
> Fixes: 81dee67e215b ("staging: sm750fb: add sm750 to staging")
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>

How was this found and tested?

And why are you doing multiple things in the same patch?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: sm750fb: Unmap PCI resources on framebuffer probe failure
  2026-12-02  7:39 ` Greg KH
@ 2026-12-02  7:58   ` Haoxiang Li
  2026-12-02  8:01     ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Haoxiang Li @ 2026-12-02  7:58 UTC (permalink / raw)
  To: Greg KH; +Cc: sudipm.mukherjee, teddy.wang, linux-fbdev, linux-staging


Hi,

At 2026-12-02 15:39:28, "Greg KH" <gregkh@linuxfoundation.org> wrote:

>
>How was this found and tested?
>

I found this with a static checker I wrote. I then used a userspace harness
to confirm that the probe leaves these resources allocated when allocation
returns an error. The patch is compiled but not tested on real hardware
because I don't have an SM750 device.

>And why are you doing multiple things in the same patch?
>

I included arch_phys_wc_del() because I noticed this is also a missing
when I manual reviewed. I will drop this if it isn't appropriate here.

Best Regards,
Haoxiang Li

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: sm750fb: Unmap PCI resources on framebuffer probe failure
  2026-12-02  7:58   ` Haoxiang Li
@ 2026-12-02  8:01     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2026-12-02  8:01 UTC (permalink / raw)
  To: Haoxiang Li; +Cc: sudipm.mukherjee, teddy.wang, linux-fbdev, linux-staging

On Wed, Dec 02, 2026 at 03:58:07PM +0800, Haoxiang Li wrote:
> 
> Hi,
> 
> At 2026-12-02 15:39:28, "Greg KH" <gregkh@linuxfoundation.org> wrote:
> 
> >
> >How was this found and tested?
> >
> 
> I found this with a static checker I wrote. I then used a userspace harness
> to confirm that the probe leaves these resources allocated when allocation
> returns an error. The patch is compiled but not tested on real hardware
> because I don't have an SM750 device.

Please read: https://lore.kernel.org/r/2026080354-skater-urgent-31b2@gregkh

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-12-02  8:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  3:37 [PATCH] staging: sm750fb: Unmap PCI resources on framebuffer probe failure Haoxiang Li
2026-12-02  7:39 ` Greg KH
2026-12-02  7:58   ` Haoxiang Li
2026-12-02  8:01     ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.