From: Zhang Rui Date: Thu, 12 Jan 2023 06:43:35 +0000 (+0800) Subject: tools/power/x86/intel-speed-select: Handle open() failure case X-Git-Tag: microblaze-v6.6~1122^2~57 X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=364ba3b7115087ab8960473a94cedc7336f345e2;p=linux-2.6-microblaze.git 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 Signed-off-by: Srinivas Pandruvada Signed-off-by: Hans de Goede --- 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);