Bug 732754

Summary: Coverity scan revealed defects
Product: Red Hat Enterprise Linux 6 Reporter: Michal Luscon <mluscon>
Component: xorg-x11-drv-intelAssignee: Adam Jackson <ajax>
Status: CLOSED WONTFIX QA Contact: desktop-bugs <desktop-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.2CC: kdudka
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-09-26 18:50:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Michal Luscon 2011-08-23 13:54:00 UTC
Description of problem:

/intel-gpu-tools-20110628/tests/gem_stress_gen6.c:506 - This greater-than-or-equal-to-zero comparison of an unsigned value is always true.

/intel-gpu-tools-20110628/tests/gem_stress.c:503 - Dereferencing "tiling" (line #502) before a null check.

/xf86-video-intel-2.16.0/src/i965_render.c:1240 - Overrunning static array "i965_tex_formats", with 13 elements, at position 13 with index variable "i".

/xf86-video-intel-2.16.0/src/intel_dri.c:885 - Dereferencing "drawable" (line #877) before a null check.


Version-Release number of selected component (if applicable):
xorg-x11-drv-intel-2.16.0-1.el6

Additional info:
These defects were not present in the previous version of package.

Comment 2 Adam Jackson 2011-09-26 18:50:02 UTC
(In reply to comment #0)
> Description of problem:
> 
> /intel-gpu-tools-20110628/tests/gem_stress_gen6.c:506 - This
> greater-than-or-equal-to-zero comparison of an unsigned value is always true.

Yeah, that's macro abuse for you.  Learn about assert() please.

> /intel-gpu-tools-20110628/tests/gem_stress.c:503 - Dereferencing "tiling" (line
> #502) before a null check.

Technically true but harmless, tiling argument is always &foo in the callers.

> /xf86-video-intel-2.16.0/src/i965_render.c:1240 - Overrunning static array
> "i965_tex_formats", with 13 elements, at position 13 with index variable "i".

Coverity bug, this path is guarded by an assert() which makes that value a can't-happen.

> /xf86-video-intel-2.16.0/src/intel_dri.c:885 - Dereferencing "drawable" (line
> #877) before a null check.

Technically true but harmless, the 'drawable' argument will be non-zero here because dixLookupDrawable() in the caller will have filled it in.

Comment 3 Kamil Dudka 2011-09-26 20:26:21 UTC
(In reply to comment #2)
> > /xf86-video-intel-2.16.0/src/i965_render.c:1240 - Overrunning static array
> > "i965_tex_formats", with 13 elements, at position 13 with index variable "i".
> 
> Coverity bug, this path is guarded by an assert() which makes that value a
> can't-happen.

True, but only for _debug_ build.  When building for production, the preprocessed code looks like this:

static uint32_t i965_get_card_format(PicturePtr picture)
{
    int i;

    for (i = 0; i < sizeof(i965_tex_formats) / sizeof(i965_tex_formats[0]);
            i++) {
        if (i965_tex_formats[i].fmt == picture->format)
            break;
    }
    ((void) (0));

    return i965_tex_formats[i].card_fmt;
}

> > /xf86-video-intel-2.16.0/src/intel_dri.c:885 - Dereferencing "drawable" (line
> > #877) before a null check.
> 
> Technically true but harmless, the 'drawable' argument will be non-zero here
> because dixLookupDrawable() in the caller will have filled it in.

Does it mean the NULL checks are there by mistake?  The NULL checks as they are now can never ever be fired...