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@xxxxxxxxxx> --- 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