b524ba277ea0b2ecff7e8b2f42b323683b83eaec
[openwrt/staging/robimarko.git] /
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
5 reset if kmalloc fails
6
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
11 pointer or not.
12
13 Make sure we don't end up accessing a NULL pointer.
14
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>
19 ---
20 drivers/gpu/drm/vc4/vc4_hdmi.c | 4 +++-
21 1 file changed, 3 insertions(+), 1 deletion(-)
22
23 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
24 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
25 @@ -216,7 +216,9 @@ static int vc4_hdmi_connector_get_modes(
26 static void vc4_hdmi_connector_reset(struct drm_connector *connector)
27 {
28 drm_atomic_helper_connector_reset(connector);
29 - drm_atomic_helper_connector_tv_reset(connector);
30 +
31 + if (connector->state)
32 + drm_atomic_helper_connector_tv_reset(connector);
33 }
34
35 static const struct drm_connector_funcs vc4_hdmi_connector_funcs = {