From e02c6663e9a42b5e8695b6a4311a15de92d47aa2 Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Wed, 5 Jun 2024 02:04:50 -0700 Subject: [PATCH] intel/tools: Fix intel_dev_info --hwconfig switch Since a42a5bf87e9, we've been closing the file descriptor immediately after loading the devinfo struct. intel_get_and_print_hwconfig_table() re-queries the hwconfig info from the device to print out all the entries, so we need to leave the fd open for this use. I moved the close() call to all paths which exit the for loop's current iteration. Ref: a42a5bf87e9 ("intel/devinfo: add an option to pick platform to print") Signed-off-by: Jordan Justen Reviewed-by: Sagar Ghuge Part-of: --- src/intel/tools/intel_dev_info.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/intel/tools/intel_dev_info.c b/src/intel/tools/intel_dev_info.c index 9a1c7451d34..aef2cd9bebb 100644 --- a/src/intel/tools/intel_dev_info.c +++ b/src/intel/tools/intel_dev_info.c @@ -254,10 +254,11 @@ main(int argc, char *argv[]) continue; bool success = intel_get_device_info_from_fd(fd, &devinfo, -1, -1); - close(fd); - if (!success) + if (!success) { + close(fd); continue; + } if (print_json) { JSON_Value *json = intel_device_info_dump_json(&devinfo); @@ -276,6 +277,7 @@ main(int argc, char *argv[]) printf("%s", pretty_string); json_free_serialized_string(pretty_string); json_value_free(json); + close(fd); continue; } @@ -287,6 +289,8 @@ main(int argc, char *argv[]) intel_get_and_print_hwconfig_table(fd, &devinfo); if (print_workarounds) print_wa_info(&devinfo); + + close(fd); } }