diff mbox series

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

Message ID 1518428694-18018-2-git-send-email-tomi.valkeinen@ti.com
State Superseded
Headers show
Series drm/omap: misc patches | expand

Commit Message

Tomi Valkeinen Feb. 12, 2018, 9:44 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>
---
 drivers/gpu/drm/omapdrm/omap_fbdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Feb. 27, 2018, 11:28 a.m. UTC | #1
Hi Tomi,

Thank you for the patch.

On Monday, 12 February 2018 11:44:31 EET 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>

I wonder whether we shouldn't fail probe if we have no CRTC or connector, but 
regardless of that, this change looks good to me.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  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)
Tomi Valkeinen Feb. 27, 2018, 11:53 a.m. UTC | #2
On 27/02/18 13:28, Laurent Pinchart wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Monday, 12 February 2018 11:44:31 EET 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>
> 
> I wonder whether we shouldn't fail probe if we have no CRTC or connector, but 
> regardless of that, this change looks good to me.

We can use the writeback without any displays.

 Tomi
diff mbox series

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)