<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Missing NULL check; radeon_drm_winsys.c"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=72732">72732</a>
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dri-devel@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missing NULL check; radeon_drm_winsys.c
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>freedesktop@treblig.org
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Drivers/DRI/R600
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I can sometime trigger a seg in do_winsys_init at radeon_drm_winsys.c on my
HD4350

There seems to be a simple missing NULL check:


214    version = drmGetVersion(ws->fd);
215    if (version->version_major != 2 ||
216        version->version_minor < 3) {

All the other users of drmGetVersion do a NULL check, so I suggest adding:

    if (!version) {
      fprintf(stderr,"%s: drmGetVersion NULL - bad fd (%d)?\n", __FUNCTION__,
ws->fd);
      return FALSE;
    }

I believe this to be part of the reason for:
<a href="https://bugzilla.redhat.com/show_bug.cgi?id=993463">https://bugzilla.redhat.com/show_bug.cgi?id=993463</a>


why drmGetVersion is failing is a different matter (probably a bad fd at that
point - but why?) , but at least the NULL check would stop the seg.

Dave</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>