dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/vmwgfx/vmwgfx_drv: Fix an error path in vmw_setup_pci_resources()
@ 2021-01-25  8:45 Dan Carpenter
  2021-01-25 19:13 ` Zack Rusin
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2021-01-25  8:45 UTC (permalink / raw)
  To: VMware Graphics, Zack Rusin
  Cc: David Airlie, Roland Scheidegger, kernel-janitors, dri-devel,
	Martin Krastev

The devm_memremap() function never returns NULL, it returns error
pointers so the test needs to be fixed.  Also we need to call
pci_release_regions() to avoid a memory leak.

Fixes: be4f77ac6884 ("drm/vmwgfx: Cleanup fifo mmio handling")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index eb997f4678de..3f603a6b5f90 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -668,9 +668,10 @@ static int vmw_setup_pci_resources(struct vmw_private *dev,
 				      fifo_size,
 				      MEMREMAP_WB);
 
-	if (unlikely(dev->fifo_mem == NULL)) {
+	if (IS_ERR(dev->fifo_mem)) {
 		DRM_ERROR("Failed mapping FIFO memory.\n");
-		return -ENOMEM;
+		pci_release_regions(pdev);
+		return PTR_ERR(dev->fifo_mem);
 	}
 
 	/*
-- 
2.29.2

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm/vmwgfx/vmwgfx_drv: Fix an error path in vmw_setup_pci_resources()
  2021-01-25  8:45 [PATCH] drm/vmwgfx/vmwgfx_drv: Fix an error path in vmw_setup_pci_resources() Dan Carpenter
@ 2021-01-25 19:13 ` Zack Rusin
  2021-01-26  7:34   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Zack Rusin @ 2021-01-25 19:13 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: David Airlie, kernel-janitors, Roland Scheidegger, dri-devel,
	Martin Krastev, Linux-graphics-maintainer



> On Jan 25, 2021, at 03:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> The devm_memremap() function never returns NULL, it returns error
> pointers so the test needs to be fixed.  Also we need to call
> pci_release_regions() to avoid a memory leak.
> 
> Fixes: be4f77ac6884 ("drm/vmwgfx: Cleanup fifo mmio handling")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, Dan.

I have a patch based on your report that fixes that too but it comes with a refactoring. I’d be happy to rebase it on top of yours just to get yours in before. If you’d like I can push your patch through drm-misc-next, if not:

Reviewed-by: Zack Rusin <zackr@vmware.com>

z


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm/vmwgfx/vmwgfx_drv: Fix an error path in vmw_setup_pci_resources()
  2021-01-25 19:13 ` Zack Rusin
@ 2021-01-26  7:34   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-01-26  7:34 UTC (permalink / raw)
  To: Zack Rusin
  Cc: David Airlie, kernel-janitors, Roland Scheidegger, dri-devel,
	Martin Krastev, Linux-graphics-maintainer

On Mon, Jan 25, 2021 at 07:13:43PM +0000, Zack Rusin wrote:
> 
> 
> > On Jan 25, 2021, at 03:45, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > 
> > The devm_memremap() function never returns NULL, it returns error
> > pointers so the test needs to be fixed.  Also we need to call
> > pci_release_regions() to avoid a memory leak.
> > 
> > Fixes: be4f77ac6884 ("drm/vmwgfx: Cleanup fifo mmio handling")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Thanks, Dan.
> 
> I have a patch based on your report that fixes that too but it comes with a refactoring. I’d be happy to rebase it on top of yours just to get yours in before. If you’d like I can push your patch through drm-misc-next, if not:


No no.  Sorry, just apply your patch and drop mine.  The problem is that
the report I sent was from kbuild and I do my devel work on a different
system so it's harder to track those emails and I forgot.

Looking at it now, the bug report I sent earlier was only for the
pci_release_regions() and not the NULL vs error pointer.  The kbuild
bot is not using full cross function analysis so it can't find those
bugs.  My dev system does much slower builds so it's a tradeoff.

regards,
dan carpenter

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2021-01-26  7:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-25  8:45 [PATCH] drm/vmwgfx/vmwgfx_drv: Fix an error path in vmw_setup_pci_resources() Dan Carpenter
2021-01-25 19:13 ` Zack Rusin
2021-01-26  7:34   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).