loader: Fix leak of kernel driver name
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 29 Jan 2020 15:50:16 +0000 (07:50 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 30 Jan 2020 18:08:17 +0000 (10:08 -0800)
This is strdup'd, it needs to be freed.

CID: 1458032
Fixes: f93bb2fb102 ("loader: Check if the kernel driver is i915 before loading iris")
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Sagar Ghuge <sagar.ghuge@intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3630>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3630>

src/loader/loader.c

index a2fe0a241a2278549df7fa85341075c787f28656..c896fdc336079383a54e7d61cb9eb67d92e96718 100644 (file)
@@ -118,7 +118,10 @@ bool
 is_kernel_i915(int fd)
 {
    char *kernel_driver = loader_get_kernel_driver_name(fd);
-   return kernel_driver && strcmp(kernel_driver, "i915") == 0;
+   bool is_i915 = kernel_driver && strcmp(kernel_driver, "i915") == 0;
+
+   free(kernel_driver);
+   return is_i915;
 }
 
 #if defined(HAVE_LIBDRM)