All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] drm/sun4i: hdmi: Check for null pointer before cleanup
@ 2019-12-16 14:43 ` Stefan Mavrodiev
  0 siblings, 0 replies; 24+ messages in thread
From: Stefan Mavrodiev @ 2019-12-16 14:43 UTC (permalink / raw)
  To: Maxime Ripard, Chen-Yu Tsai, David Airlie, Daniel Vetter,
	open list:DRM DRIVERS FOR ALLWINNER A10,
	moderated list:ARM/Allwinner sunXi SoC support, open list
  Cc: linux-sunxi, Stefan Mavrodiev

It's possible hdmi->connector and hdmi->encoder divices to be NULL.
This can happen when building as kernel module and you try to remove
the module.

This patch make simple null check, before calling the cleanup functions.

Signed-off-by: Stefan Mavrodiev <stefan@olimex.com>
---
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
index a7c4654445c7..b61e00f2ecb8 100644
--- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
+++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c
@@ -685,8 +685,10 @@ static void sun4i_hdmi_unbind(struct device *dev, struct device *master,
 	struct sun4i_hdmi *hdmi = dev_get_drvdata(dev);
 
 	cec_unregister_adapter(hdmi->cec_adap);
-	drm_connector_cleanup(&hdmi->connector);
-	drm_encoder_cleanup(&hdmi->encoder);
+	if (hdmi->connector.dev)
+		drm_connector_cleanup(&hdmi->connector);
+	if (hdmi->encoder.dev)
+		drm_encoder_cleanup(&hdmi->encoder);
 	i2c_del_adapter(hdmi->i2c);
 	i2c_put_adapter(hdmi->ddc_i2c);
 	clk_disable_unprepare(hdmi->mod_clk);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2019-12-18  8:13 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-16 14:43 [PATCH 1/1] drm/sun4i: hdmi: Check for null pointer before cleanup Stefan Mavrodiev
2019-12-16 14:43 ` Stefan Mavrodiev
2019-12-16 14:43 ` Stefan Mavrodiev
2019-12-16 16:12 ` Maxime Ripard
2019-12-16 16:12   ` Maxime Ripard
2019-12-16 16:12   ` Maxime Ripard
2019-12-17  6:45   ` Stefan Mavrodiev
2019-12-17  6:45     ` Stefan Mavrodiev
2019-12-17  6:45     ` Stefan Mavrodiev
2019-12-17 11:46     ` Maxime Ripard
2019-12-17 11:46       ` Maxime Ripard
2019-12-17 11:46       ` Maxime Ripard
2019-12-17 11:49       ` Maxime Ripard
2019-12-17 11:49         ` Maxime Ripard
2019-12-17 11:49         ` Maxime Ripard
2019-12-17 11:54         ` Stefan Mavrodiev
2019-12-17 11:54           ` Stefan Mavrodiev
2019-12-17 11:54           ` Stefan Mavrodiev
2019-12-17 11:57           ` Maxime Ripard
2019-12-17 11:57             ` Maxime Ripard
2019-12-17 11:57             ` Maxime Ripard
2019-12-17  7:26 ` Uwe Kleine-König
2019-12-17  7:26   ` Uwe Kleine-König
2019-12-17  7:26   ` Uwe Kleine-König

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.