Hi,

On 27/08/13 04:20, Dan Carpenter wrote:
> 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);
> 

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.
    
    Signed-off-by: Tomi Valkeinen <[email protected]>

diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index 44a885b..ea97854 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -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);
 }


Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to