From c11ad5a800881a9f53e9fabc92e5ac213b492b6c Mon Sep 17 00:00:00 2001 From: John Johansen Date: Sat, 25 Oct 2014 16:26:59 -0400 Subject: [PATCH] fix: parser: close of fd with value of -1 Both valgrind and strace report the parser doing close(-1) = -1 EBADF (Bad file descriptor) This happens the skip kernel load argument is specified in combination with any of --add, --replace, or --remove arguments (the default is --add if no other option is specified). This happens when the parser is not processing profiles but not writing them out (eg. no kernel load, dump to stdout, file ...) Signed-off-by: John Johansen Acked-by: Steve Beattie --- parser/parser_interface.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parser/parser_interface.c b/parser/parser_interface.c index 855e09f2f..0d6626d97 100644 --- a/parser/parser_interface.c +++ b/parser/parser_interface.c @@ -597,7 +597,8 @@ int __sd_serialize_profile(int option, Profile *prof) } } - close(fd); + if (fd != -1) + close(fd); if (!prof->hat_table.empty() && option != OPTION_REMOVE) { if (load_flattened_hats(prof, option) == 0)