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

Submitted by Kirill Tkhai on June 21, 2017, 10:35 a.m.

Details

Message ID 149804131516.7468.9636717713785400130.stgit@localhost.localdomain
State New
Series "Series without cover letter"
Headers show

Commit Message

Kirill Tkhai June 21, 2017, 10:35 a.m.
----------------------------------------------------------------
*** 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@virtuozzo.com>
---
 criu/kerndat.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

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);