From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Eric Anholt <eric@anholt.net>
Cc: Boris Brezillon <boris.brezillon@bootlin.com>,
dri-devel@lists.freedesktop.org
Subject: [PATCH 1/2] drm/vc4: Fix NULL pointer dereference in the async update path
Date: Tue, 13 Nov 2018 10:49:13 +0100 [thread overview]
Message-ID: <20181113094914.22353-1-boris.brezillon@bootlin.com> (raw)
vc4_plane_atomic_async_update() calls vc4_plane_atomic_check()
which in turn calls vc4_plane_setup_clipping_and_scaling(), and since
commit 58a6a36fe8e0 ("drm/vc4: Use
drm_atomic_helper_check_plane_state() to simplify the logic"), this
function accesses plane_state->state which will be NULL when called
from the async update path since we're passing previous plane state,
and plane_state->state has been assigned to NULL in
drm_atomic_helper_swap_state().
Assign plane->state->state to new_plane_state->state before calling
vc4_plane_atomic_check() and reset it to NULL after
vc4_plane_atomic_check() as returned.
Fixes: 58a6a36fe8e0 ("drm/vc4: Use drm_atomic_helper_check_plane_state() to simplify the logic")
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
---
drivers/gpu/drm/vc4/vc4_plane.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c
index 9dc3fcbd290b..c33c7dc2119d 100644
--- a/drivers/gpu/drm/vc4/vc4_plane.c
+++ b/drivers/gpu/drm/vc4/vc4_plane.c
@@ -827,8 +827,13 @@ static void vc4_plane_atomic_async_update(struct drm_plane *plane,
plane->state->src_x = state->src_x;
plane->state->src_y = state->src_y;
- /* Update the display list based on the new crtc_x/y. */
+ /* Update the display list based on the new crtc_x/y.
+ * The plane->state->state update dance is needed to avoid NULL pointer
+ * dereference in vc4_plane_setup_clipping_and_scaling().
+ */
+ plane->state->state = state->state;
vc4_plane_atomic_check(plane, plane->state);
+ plane->state->state = NULL;
/* Note that we can't just call vc4_plane_write_dlist()
* because that would smash the context data that the HVS is
--
2.17.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next reply other threads:[~2018-11-13 9:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-13 9:49 Boris Brezillon [this message]
2018-11-13 9:49 ` [PATCH 2/2] drm/vc4: Set ->legacy_cursor_update to false when doing non-async updates Boris Brezillon
2018-11-13 21:18 ` Eric Anholt
2018-11-13 21:24 ` [PATCH 1/2] drm/vc4: Fix NULL pointer dereference in the async update path Eric Anholt
2018-11-13 22:18 ` Boris Brezillon
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=20181113094914.22353-1-boris.brezillon@bootlin.com \
--to=boris.brezillon@bootlin.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=eric@anholt.net \
/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