[Bug 100011] New: src/intel_device.c reverses return value meaning of xorg server xf86LoadKernelModule()

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue Feb 28 20:29:24 UTC 2017


https://bugs.freedesktop.org/show_bug.cgi?id=100011

            Bug ID: 100011
           Summary: src/intel_device.c reverses return value meaning of
                    xorg server xf86LoadKernelModule()
           Product: xorg
           Version: git
          Hardware: Other
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: medium
         Component: Driver/intel
          Assignee: chris at chris-wilson.co.uk
          Reporter: davshao at gmail.com
        QA Contact: intel-gfx-bugs at lists.freedesktop.org

The function load_i915_kernel_module() in file src/intel_device.c
of xf86-video-intel reverses the meaning of the return value of
xorg server's xf86LoadKernelModule().  xf86LoadKernelModule()
actually returns 0 if the loading fails, non-zero if success.

For example, from xorg server 1.19.1's source code,
file hw/xfree86/os-support/linux/lnx_kmod.c:

 * Input:
 *    modName - name of the kernel module (Ex: "tdfx")
 * Return:
 *    0 for failure, 1 for success
 */
int
xf86LoadKernelModule(const char *modName)

        if (WIFEXITED(status) && WEXITSTATUS(status) == 0) {
            return 1;           /* success! */
        }
        else {
            return 0;
        }

And from file hw/xfree86/os-support/bsd/bsd_kmod.c

 * Return:
 *    0 for failure, 1 for success
 */
int
xf86LoadKernelModule(const char *modName)
{
    if (kldload(modName) != -1)
        return 1;
    else
        return 0;
}

On FreeBSD there is an additional complication that if
"i915kms" is added to kernel_module_names, the inverted use
of the return value causes both i915kms.ko and i915.ko to
be loaded.

Therefore I believe a patch similar to the following needs to be made
to src/intel_device.c:

@@ -233,9 +242,8 @@ static int load_i915_kernel_module(void)
        const char **kn;

        for (kn = kernel_module_names; *kn; kn++)
-               if (xf86LoadKernelModule(*kn) == 0)
+               if (xf86LoadKernelModule(*kn))
                        return 0;
-
        return -1;
 }

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/intel-gfx-bugs/attachments/20170228/7d9dcd6f/attachment.html>


More information about the intel-gfx-bugs mailing list