From f0061277c00d269d4e1530c4d85de7184e793bf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=9Alusarz?= Date: Wed, 4 Nov 2020 18:23:31 +0100 Subject: [PATCH] intel/tools: handle some failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addresses "Dereference null return value" issues reported by Coverity. Signed-off-by: Marcin Ĺšlusarz Reviewed-by: Lionel Landwerlin Part-of: --- 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")) {