Re: [PATCH v2] staging: sm750fb: fix resource leaks on probe error

From: Timofey Zakharcuk

Date: Mon Oct 19 2026 - 07:47:40 EST


hi Greg,
it was found by manual code inspection by noticing the asymmetry
between the resources
allocated pci probe (and freed in pci remove ) versus the cleanup
performed in the release_fb error path:

it was verified with checkpatch.pl
i don't have access to the physical sm750 hardware to test on real silicon.

thanks,
Tymofiy
(resending this because i accidentally sended it with html)

On Tue, Oct 13, 2026 at 4:39 PM Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Sat, Oct 03, 2026 at 08:50:55PM +0300, Tymofiy Zakharchuk wrote:
> > If sm750fb_framebuffer_alloc() fails during lynxfb_pci_probe(), only
> > the framebuffer structures are released. The write-combining MTRR,
> > the MMIO and VRAM mappings, and PCI region 1 remain allocated.
> >
> > Call arch_phys_wc_del(), iounmap(), and pci_release_region() on the
> > release_fb error exit path to prevent leaking resources.
> >
> > Signed-off-by: Tymofiy Zakharchuk <timofey.zakharchuk.research@xxxxxxxxx>
> > ---
> > v2:
> > - Fix From and Signed-off-by email mismatch.
> >
> > drivers/staging/sm750fb/sm750.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
> > index 8b93bfeb2..456b3da86 100644
> > --- a/drivers/staging/sm750fb/sm750.c
> > +++ b/drivers/staging/sm750fb/sm750.c
> > @@ -1023,6 +1023,10 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
> >
> > release_fb:
> > sm750fb_framebuffer_release(sm750_dev);
> > + arch_phys_wc_del(sm750_dev->mtrr.vram);
> > + iounmap(sm750_dev->vmem);
> > + iounmap(sm750_dev->mmio);
> > + pci_release_region(pdev, 1);
> > return err;
> > }
> >
> > --
> > 2.53.0.windows.1
> >
> >
>
> How was this found and tested?
>
> thanks,
>
> greg k-h