Skip to contentSkip to conversation

OMAPDSS: remove dispc's dependency to VENC/HDMI

DISCUSSION Dan Carpenter 2 participants 2 messages Aug 27, 2013 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

Hello Tomi Valkeinen,

This is a semi-automatic email about new static checker warnings.

The patch 5391e87d1259: "OMAPDSS: remove dispc's dependency to VENC/HDMI" from May 16, 2013, leads to the following Smatch complaint:

drivers/video/omap2/dss/hdmi.c:672 omapdss_hdmi_display_set_timing()
error: we previously assumed 't' could be null (see line 669)

drivers/video/omap2/dss/hdmi.c
668 t = hdmi_get_timings();
669 if (t != NULL)

                    ^^^^^^^^^

Existing check.

670 hdmi.ip_data.cfg = *t;
671

   672		dispc_set_tv_pclk(t->timings.pixel_clock * 1000);
                                  ^^^^^^^^^^^^^^^^^^^^^^

Patch added a dereference.

   673	
   674		mutex_unlock(&hdmi.lock);

regards,
dan carpenter

#1 lore raw

Hi,

Quoted 16 lines · Dan Carpenter

Hello Tomi Valkeinen,

This is a semi-automatic email about new static checker warnings.

The patch 5391e87d1259: "OMAPDSS: remove dispc's dependency to VENC/HDMI" from May 16, 2013, leads to the following Smatch complaint:

drivers/video/omap2/dss/hdmi.c:672 omapdss_hdmi_display_set_timing()
error: we previously assumed 't' could be null (see line 669)

drivers/video/omap2/dss/hdmi.c

   668		t = hdmi_get_timings();
   669		if (t != NULL)
                    ^^^^^^^^^

Existing check.

Quoted 9 lines
   670			hdmi.ip_data.cfg = *t;
   671	
   672		dispc_set_tv_pclk(t->timings.pixel_clock * 1000);
                                  ^^^^^^^^^^^^^^^^^^^^^^

Patch added a dereference.

   673	
   674		mutex_unlock(&hdmi.lock);

Thanks. I've made a fix, below.

Tomi

commit 70218db3effca57252625042a2b2c740fd3604ba (HEAD, work/fixes)

Author: Tomi Valkeinen <[email protected]>
Date:   Tue Aug 27 14:11:48 2013 +0300

OMAPDSS: HDMI: Fix possible NULL reference

Commit 5391e87d1259 (OMAPDSS: remove dispc's dependency to VENC/HDMI) introduced a possible NULL reference bug in the HDMI driver when setting timings. In practice the bug shouldn't happen, as the timings have been verified earlier, and thus the timings should always be ok.

Fix the possible issue by moving the use of the timings pointer inside the NULL check.

drivers/video/omap2/dss/hdmi.c +3 -2
index 44a885b..ea97854 100644
@@ -666,10 +666,11 @@ void omapdss_hdmi_display_set_timing(struct omap_dss_device *dssdev,
 	hdmi.ip_data.cfg.cm = cm;
 
 	t = hdmi_get_timings();
-	if (t != NULL)
+	if (t != NULL) {
 		hdmi.ip_data.cfg = *t;
 
-	dispc_set_tv_pclk(t->timings.pixel_clock * 1000);
+		dispc_set_tv_pclk(t->timings.pixel_clock * 1000);
+	}
 
 	mutex_unlock(&hdmi.lock);
 }