[Mesa-dev] [PATCH 8/8] loader: cleanup loader_get_device_name_for_fd error path

Emil Velikov emil.l.velikov at gmail.com
Thu Feb 6 16:46:54 PST 2014


Make sure that we unref the udev, if we fail to retrieve the device.

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/loader/loader.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/loader/loader.c b/src/loader/loader.c
index d75380b..422079a 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -485,15 +485,14 @@ loader_get_device_name_for_fd(int fd)
    udev = udev_new();
    device = udev_device_new_from_fd(udev, fd);
    if (device == NULL)
-      return NULL;
+      goto out_unref;
 
    const_device_name = udev_device_get_devnode(device);
-   if (!const_device_name)
-      goto out;
-   device_name = strdup(const_device_name);
+   if (const_device_name != NULL)
+      device_name = strdup(const_device_name);
 
-out:
    udev_device_unref(device);
+out_unref:
    udev_unref(udev);
 #endif
    return device_name;
-- 
1.8.5.2



More information about the mesa-dev mailing list