summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2023-01-12 14:43:35 +0800
committerHans de Goede <hdegoede@redhat.com>2023-02-03 09:56:58 +0100
commit364ba3b7115087ab8960473a94cedc7336f345e2 (patch)
treeb600c0153eac302fa6f71c73eb3eef48270b41b8
parentb8bebc8e58d5dc8f2c528b0be4e858959c48e340 (diff)
tools/power/x86/intel-speed-select: Handle open() failure case
Add handling for open() failure case to make sure a valid file descriptor is passed to dup(). Signed-off-by: Zhang Rui <rui.zhang@intel.com> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--tools/power/x86/intel-speed-select/isst-daemon.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/power/x86/intel-speed-select/isst-daemon.c b/tools/power/x86/intel-speed-select/isst-daemon.c
index 0699137c0901..4ad6a64f1545 100644
--- a/tools/power/x86/intel-speed-select/isst-daemon.c
+++ b/tools/power/x86/intel-speed-select/isst-daemon.c
@@ -174,6 +174,8 @@ static void daemonize(char *rundir, char *pidfile)
close(i);
i = open("/dev/null", O_RDWR);
+ if (i < 0)
+ exit(EXIT_FAILURE);
ret = dup(i);
if (ret == -1)
exit(EXIT_FAILURE);