Mesa (master): anv: strdup the device path into the physical device

Jason Ekstrand jekstrand at kemper.freedesktop.org
Sat May 28 00:18:49 UTC 2016


Module: Mesa
Branch: master
Commit: e023c104f738d030c21a519e805705961e4ccf46
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e023c104f738d030c21a519e805705961e4ccf46

Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date:   Tue May 24 11:02:18 2016 -0700

anv: strdup the device path into the physical device

This way we don't have to assume that the string coming in is a piece of
constant data that exists forever.

---

 src/intel/vulkan/anv_device.c  | 4 +++-
 src/intel/vulkan/anv_private.h | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index eb40e2d..1ab6c74 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -67,7 +67,9 @@ anv_physical_device_init(struct anv_physical_device *device,
 
    device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
    device->instance = instance;
-   device->path = path;
+
+   assert(strlen(path) < ARRAY_SIZE(device->path));
+   strncpy(device->path, path, ARRAY_SIZE(device->path));
 
    device->chipset_id = anv_gem_get_param(fd, I915_PARAM_CHIPSET_ID);
    if (!device->chipset_id) {
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index b3774a8..7325f3f 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -542,7 +542,7 @@ struct anv_physical_device {
 
     struct anv_instance *                       instance;
     uint32_t                                    chipset_id;
-    const char *                                path;
+    char                                        path[20];
     const char *                                name;
     const struct brw_device_info *              info;
     uint64_t                                    aperture_size;




More information about the mesa-commit mailing list