[Devel] [PATCH 3/3] kerndat: Silence coverity warning in kerndat_has_ns_get_parent()

Kirill Tkhai ktkhai at virtuozzo.com
Wed Jun 21 13:35:22 MSK 2017


----------------------------------------------------------------
*** CID 181218:  Error handling issues  (NEGATIVE_RETURNS)
/criu/kerndat.c: 692 in kerndat_has_ns_get_parent()
686                     return -1;
687             }
688
689             p_ns = ioctl(ns, NS_GET_PARENT);
690             if (p_ns >= 0 || errno == EPERM) {
691                     kdat.has_ns_get_parent = true;
>>>     CID 181218:  Error handling issues  (NEGATIVE_RETURNS)
>>>     "p_ns" is passed to a parameter that cannot be negative.
692                     close(p_ns);
693             }
694
695             close(ns);
696             return 0;
697     }
----------------------------------------------------------------

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/kerndat.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/criu/kerndat.c b/criu/kerndat.c
index 5bca4bfc9..6a3a4de3f 100644
--- a/criu/kerndat.c
+++ b/criu/kerndat.c
@@ -689,7 +689,7 @@ int kerndat_has_ns_get_parent(void)
 	p_ns = ioctl(ns, NS_GET_PARENT);
 	if (p_ns >= 0 || errno == EPERM) {
 		kdat.has_ns_get_parent = true;
-		close(p_ns);
+		close_safe(&p_ns);
 	}
 
 	close(ns);



More information about the Devel mailing list