dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Christ <contact@stefanchrist.eu>
To: dri-devel@lists.freedesktop.org
Subject: [PATCH v2 01/18] drm/fb-helper: fix segfaults in drm_fb_helper_debug_*
Date: Mon, 14 Nov 2016 00:03:11 +0100	[thread overview]
Message-ID: <1479078208-25221-2-git-send-email-contact@stefanchrist.eu> (raw)
In-Reply-To: <1479078208-25221-1-git-send-email-contact@stefanchrist.eu>

A drm driver that is implementing

      fb_debug_enter and fb_debug_leave

in struct fb_ops with drm fb helper functions

     drm_fb_helper_debug_enter and drm_fb_helper_debug_leave

must also implement the callback 'mode_set_base_atomic' in struct
drm_crtc_helper_funcs. See Documentation/DocBook/kgdb.tmpl.  The current
implementation will segfault when 'mode_set_base_atomic' is a NULL
pointer.

Before this patch at least the drm drivers armada, ast, qxl, udl and
virtio do not have a 'mode_set_base_atomic' implementation but using
drm_fb_helper_debug_(enter|leave). So these drivers may segfault when
callbacks fb_debug_(enter|leave) are called.

Avoid the issue by just checking for NULL pointers. So all drivers can
unconditionally implement fb_debug_(enter|leave) with the drm_fb_helper
functions. If callback 'mode_set_base_atomic' is not implemented, the
code in drm_fb_helper_debug_(enter|leave) does effectively nothing.

Signed-off-by: Stefan Christ <contact@stefanchrist.eu>
---
 drivers/gpu/drm/drm_fb_helper.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 03414bd..823fc9e 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -251,6 +251,9 @@ int drm_fb_helper_debug_enter(struct fb_info *info)
 				continue;
 
 			funcs =	mode_set->crtc->helper_private;
+			if (funcs->mode_set_base_atomic == NULL)
+				continue;
+
 			drm_fb_helper_save_lut_atomic(mode_set->crtc, helper);
 			funcs->mode_set_base_atomic(mode_set->crtc,
 						    mode_set->fb,
@@ -304,6 +307,9 @@ int drm_fb_helper_debug_leave(struct fb_info *info)
 			continue;
 		}
 
+		if (funcs->mode_set_base_atomic == NULL)
+			continue;
+
 		drm_fb_helper_restore_lut_atomic(mode_set->crtc);
 		funcs->mode_set_base_atomic(mode_set->crtc, fb, crtc->x,
 					    crtc->y, LEAVE_ATOMIC_MODE_SET);
-- 
2.7.3

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

  reply	other threads:[~2016-11-13 23:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-13 23:03 [PATCH v2 00/18] Introduce DRM_FB_HELPER_DEFAULT_OPS for struct fb_ops Stefan Christ
2016-11-13 23:03 ` Stefan Christ [this message]
2016-11-13 23:03 ` [PATCH v2 02/18] drm/fb-helper: add fb_debug_* to DRM_FB_HELPER_DEFAULT_OPS Stefan Christ
2016-11-13 23:03 ` [PATCH v2 03/18] drm/amdgpu: use DRM_FB_HELPER_DEFAULT_OPS for fb_ops Stefan Christ
2016-11-13 23:03 ` [PATCH v2 04/18] drm/armada: " Stefan Christ
2016-11-13 23:03 ` [PATCH v2 05/18] drm/bochs: " Stefan Christ
2016-11-13 23:03 ` [PATCH v2 06/18] drm/fb_cma_helper: " Stefan Christ
2016-11-13 23:03 ` [PATCH v2 07/18] drm/exynos: " Stefan Christ
2016-11-13 23:03 ` [PATCH v2 08/18] drm/nouveau: " Stefan Christ
2016-11-13 23:03 ` [PATCH v2 09/18] drm/qxl: " Stefan Christ
2016-11-13 23:03 ` [PATCH v2 10/18] drm/rockchip: " Stefan Christ
2016-11-13 23:03 ` [PATCH v2 11/18] drm/radeon: " Stefan Christ
2016-11-13 23:03 ` [PATCH v2 12/18] drm/tegra: " Stefan Christ
2016-11-13 23:03 ` [PATCH v2 13/18] drm/udl: " Stefan Christ
2016-11-13 23:03 ` [PATCH v2 14/18] drm/msm: " Stefan Christ
2016-11-13 23:03 ` [PATCH v2 15/18] drm/virtio: " Stefan Christ
2016-11-13 23:03 ` [PATCH v2 16/18] drm/omapdrm: " Stefan Christ
2016-11-13 23:03 ` [PATCH v2 17/18] drm/i915: " Stefan Christ
2016-11-13 23:03 ` [PATCH v2 18/18] drm/gma500: " Stefan Christ
2016-11-14  7:02 ` [PATCH v2 00/18] Introduce DRM_FB_HELPER_DEFAULT_OPS for struct fb_ops Daniel Vetter
2016-11-14  9:43 ` Christian König
2016-11-14 12:37   ` Stefan Christ

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1479078208-25221-2-git-send-email-contact@stefanchrist.eu \
    --to=contact@stefanchrist.eu \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).