drm: Branch 'master' - 2 commits

[email protected] (Emil Velikov)
Newsgroups gmane.comp.video.dri.patches
Message-ID <[email protected]>
 xf86drm.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

New commits:
commit ba5a6ecf81fc2e25a4c7b8c592143faadfdd63db
Author: Matt Roper <[email protected]>
Date:   Fri Oct 16 15:11:24 2015 -0700

    xf86drm: Handle unrecognized subsystems safely in drmGetDevice[s]()
    
    Both drmGetDevice() and drmGetDevices() currently print a warning when
    they encounter an unknown (non-PCI) subsystem type for a device node,
    but they still proceed to assume that the drmDevicePtr was initialized
    and try to add it to the local device array.  Add a 'continue' to the
    error case handling to bypass the rest of the processing for devices we
    can't handle.
    
    Signed-off-by: Matt Roper <[email protected]>
    Reviewed-by: Alex Deucher <[email protected]>
    Reviewed-by: Emil Velikov <[email protected]>

diff --git a/xf86drm.c b/xf86drm.c
index 951edbb..7e28b4f 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -3140,7 +3140,7 @@ int drmGetDevice(int fd, drmDevicePtr *device)
             break;
         default:
             fprintf(stderr, "The subsystem type is not supported yet\n");
-            break;
+            continue;
         }
 
         if (i >= max_count) {
@@ -3244,7 +3244,7 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices)
             break;
         default:
             fprintf(stderr, "The subsystem type is not supported yet\n");
-            break;
+            continue;
         }
 
         if (i >= max_count) {
commit cf0f036e3d819fb7894562bfdfea95e5e5f57219
Author: Matt Roper <[email protected]>
Date:   Fri Oct 16 15:11:23 2015 -0700

    xf86drm: Fix error handling for drmGetDevice()
    
    Some of the error conditions in drmGetDevice() can lead to us calling
    closedir(NULL) or leaking memory.  Fix these conditions the same way we
    did for drmGetDevices() in commit:
    
            commit 8c4a1cbd98bd8d185d489395f33302a17db643a9
            Author: Matt Roper <[email protected]>
            Date:   Wed Sep 30 09:30:51 2015 -0700
    
                xf86drm: Fix error handling for drmGetDevices()
    
    Signed-off-by: Matt Roper <[email protected]>
    Reviewed-by: Emil Velikov <[email protected]>

diff --git a/xf86drm.c b/xf86drm.c
index a29db42..951edbb 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -3108,7 +3108,7 @@ int drmGetDevice(int fd, drmDevicePtr *device)
     sysdir = opendir(DRM_DIR_NAME);
     if (!sysdir) {
         ret = -errno;
-        goto close_sysdir;
+        goto free_locals;
     }
 
     i = 0;
@@ -3165,16 +3165,16 @@ int drmGetDevice(int fd, drmDevicePtr *device)
     for (i = 1; i < node_count && local_devices[i]; i++)
             drmFreeDevice(&local_devices[i]);
 
-    free(local_devices);
     closedir(sysdir);
+    free(local_devices);
     return 0;
 
 free_devices:
     drmFreeDevices(local_devices, i);
-    free(local_devices);
-
-close_sysdir:
     closedir(sysdir);
+
+free_locals:
+    free(local_devices);
     return ret;
 }
 

------------------------------------------------------------------------------
--
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.