Commit 364ba3b7 authored by Zhang Rui's avatar Zhang Rui Committed by Hans de Goede

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: default avatarZhang Rui <rui.zhang@intel.com>
Signed-off-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent b8bebc8e
...@@ -174,6 +174,8 @@ static void daemonize(char *rundir, char *pidfile) ...@@ -174,6 +174,8 @@ static void daemonize(char *rundir, char *pidfile)
close(i); close(i);
i = open("/dev/null", O_RDWR); i = open("/dev/null", O_RDWR);
if (i < 0)
exit(EXIT_FAILURE);
ret = dup(i); ret = dup(i);
if (ret == -1) if (ret == -1)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment