[1/4] drm: Make drm_fb_unregister/remove accept NULL fb
diff mbox

Message ID 1440510314-8633-1-git-send-email-daniel.vetter@ffwll.ch
State New
Headers show

Commit Message

Daniel Vetter Aug. 25, 2015, 1:45 p.m. UTC
These functions are used by drivers to release fbdev emulation
buffers. We need to make them resilient to NULL pointers to
make the fbdev compile/runtime knobs not cause Oopses on module
unload.

Cc: Archit Taneja <architt@codeaurora.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_crtc.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Rob Clark Aug. 25, 2015, 7:19 p.m. UTC | #1
On Tue, Aug 25, 2015 at 9:45 AM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> These functions are used by drivers to release fbdev emulation
> buffers. We need to make them resilient to NULL pointers to
> make the fbdev compile/runtime knobs not cause Oopses on module
> unload.
>
> Cc: Archit Taneja <architt@codeaurora.org>
> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

Reviewed-by: Rob Clark <robdclark@gmail.com>

> ---
>  drivers/gpu/drm/drm_crtc.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 33d877c65ced..884690c81094 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -538,7 +538,12 @@ EXPORT_SYMBOL(drm_framebuffer_reference);
>   */
>  void drm_framebuffer_unregister_private(struct drm_framebuffer *fb)
>  {
> -       struct drm_device *dev = fb->dev;
> +       struct drm_device *dev;
> +
> +       if (!fb)
> +               return;
> +
> +       dev = fb->dev;
>
>         mutex_lock(&dev->mode_config.fb_lock);
>         /* Mark fb as reaped and drop idr ref. */
> @@ -589,12 +594,17 @@ EXPORT_SYMBOL(drm_framebuffer_cleanup);
>   */
>  void drm_framebuffer_remove(struct drm_framebuffer *fb)
>  {
> -       struct drm_device *dev = fb->dev;
> +       struct drm_device *dev;
>         struct drm_crtc *crtc;
>         struct drm_plane *plane;
>         struct drm_mode_set set;
>         int ret;
>
> +       if (!fb)
> +               return;
> +
> +       dev = fb->dev;
> +
>         WARN_ON(!list_empty(&fb->filp_head));
>
>         /*
> --
> 1.8.3.1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Patch
diff mbox

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 33d877c65ced..884690c81094 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -538,7 +538,12 @@  EXPORT_SYMBOL(drm_framebuffer_reference);
  */
 void drm_framebuffer_unregister_private(struct drm_framebuffer *fb)
 {
-	struct drm_device *dev = fb->dev;
+	struct drm_device *dev;
+
+	if (!fb)
+		return;
+
+	dev = fb->dev;
 
 	mutex_lock(&dev->mode_config.fb_lock);
 	/* Mark fb as reaped and drop idr ref. */
@@ -589,12 +594,17 @@  EXPORT_SYMBOL(drm_framebuffer_cleanup);
  */
 void drm_framebuffer_remove(struct drm_framebuffer *fb)
 {
-	struct drm_device *dev = fb->dev;
+	struct drm_device *dev;
 	struct drm_crtc *crtc;
 	struct drm_plane *plane;
 	struct drm_mode_set set;
 	int ret;
 
+	if (!fb)
+		return;
+
+	dev = fb->dev;
+
 	WARN_ON(!list_empty(&fb->filp_head));
 
 	/*