diff mbox

[PATCHv2,01/17] drm/omap: fix omap_fbdev_free() when omap_fbdev_create() wasn't called

Message ID 1519817174-20714-2-git-send-email-tomi.valkeinen@ti.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tomi Valkeinen Feb. 28, 2018, 11:25 a.m. UTC
If we have no crtcs/connectors, fbdev init goes fine, but
omap_fbdev_create() is never called. This means that omap_fbdev->bo is
NULL and omap_fbdev_free() crashes.

Add a check to omap_fbdev_free() to handle the NULL case.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/gpu/drm/omapdrm/omap_fbdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Sebastian Reichel June 10, 2018, 12:22 p.m. UTC | #1
Hi,

On Wed, Feb 28, 2018 at 01:25:58PM +0200, Tomi Valkeinen wrote:
> If we have no crtcs/connectors, fbdev init goes fine, but
> omap_fbdev_create() is never called. This means that omap_fbdev->bo is
> NULL and omap_fbdev_free() crashes.
> 
> Add a check to omap_fbdev_free() to handle the NULL case.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---

Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>

-- Sebastian

>  drivers/gpu/drm/omapdrm/omap_fbdev.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c
> index 1ace63e2ff22..632ebcf2165f 100644
> --- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
> +++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
> @@ -303,7 +303,8 @@ void omap_fbdev_free(struct drm_device *dev)
>  	fbdev = to_omap_fbdev(priv->fbdev);
>  
>  	/* unpin the GEM object pinned in omap_fbdev_create() */
> -	omap_gem_unpin(fbdev->bo);
> +	if (fbdev->bo)
> +		omap_gem_unpin(fbdev->bo);
>  
>  	/* this will free the backing object */
>  	if (fbdev->fb)
> -- 
> Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
> Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/omapdrm/omap_fbdev.c b/drivers/gpu/drm/omapdrm/omap_fbdev.c
index 1ace63e2ff22..632ebcf2165f 100644
--- a/drivers/gpu/drm/omapdrm/omap_fbdev.c
+++ b/drivers/gpu/drm/omapdrm/omap_fbdev.c
@@ -303,7 +303,8 @@  void omap_fbdev_free(struct drm_device *dev)
 	fbdev = to_omap_fbdev(priv->fbdev);
 
 	/* unpin the GEM object pinned in omap_fbdev_create() */
-	omap_gem_unpin(fbdev->bo);
+	if (fbdev->bo)
+		omap_gem_unpin(fbdev->bo);
 
 	/* this will free the backing object */
 	if (fbdev->fb)