1 From e1b4f5c3970e14abe197f328077b348b4969e68f Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Tue, 15 Dec 2020 16:42:38 +0100
4 Subject: [PATCH] drm/vc4: hdmi: Don't access the connector state in
7 drm_atomic_helper_connector_reset uses kmalloc which, from an API
8 standpoint, can fail, and thus setting connector->state to NULL.
9 However, our reset hook then calls drm_atomic_helper_connector_tv_reset
10 that will access connector->state without checking if it's a valid
13 Make sure we don't end up accessing a NULL pointer.
15 Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
16 Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
17 Suggested-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
18 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
20 drivers/gpu/drm/vc4/vc4_hdmi.c | 4 +++-
21 1 file changed, 3 insertions(+), 1 deletion(-)
23 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
24 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
25 @@ -215,7 +215,9 @@ static int vc4_hdmi_connector_get_modes(
26 static void vc4_hdmi_connector_reset(struct drm_connector *connector)
28 drm_atomic_helper_connector_reset(connector);
29 - drm_atomic_helper_connector_tv_reset(connector);
31 + if (connector->state)
32 + drm_atomic_helper_connector_tv_reset(connector);
35 static const struct drm_connector_funcs vc4_hdmi_connector_funcs = {