Mesa (master): intel/tools: handle some failures

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Nov 5 12:14:33 UTC 2020


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

Author: Marcin Ślusarz <marcin.slusarz at intel.com>
Date:   Wed Nov  4 18:23:31 2020 +0100

intel/tools: handle some failures

Addresses "Dereference null return value" issues reported by Coverity.

Signed-off-by: Marcin Ślusarz <marcin.slusarz at intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7449>

---

 src/intel/tools/intel_dump_gpu.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/intel/tools/intel_dump_gpu.c b/src/intel/tools/intel_dump_gpu.c
index 197aebd5b32..812d4c481c7 100644
--- a/src/intel/tools/intel_dump_gpu.c
+++ b/src/intel/tools/intel_dump_gpu.c
@@ -446,7 +446,12 @@ maybe_init(int fd)
 
    initialized = true;
 
-   config = fopen(getenv("INTEL_DUMP_GPU_CONFIG"), "r");
+   const char *config_path = getenv("INTEL_DUMP_GPU_CONFIG");
+   fail_if(config_path == NULL, "INTEL_DUMP_GPU_CONFIG is not set\n");
+
+   config = fopen(config_path, "r");
+   fail_if(config == NULL, "failed to open file %s\n", config_path);
+
    while (fscanf(config, "%m[^=]=%m[^\n]\n", &key, &value) != EOF) {
       if (!strcmp(key, "verbose")) {
          if (!strcmp(value, "1")) {



More information about the mesa-commit mailing list