[CRIU] [PATCH] sockets: Fix potential NULL dereference

Cyrill Gorcunov gorcunov at openvz.org
Thu Apr 12 14:44:09 EDT 2012


In case if unix socket was not found don't
call for container_of.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 sockets.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/sockets.c b/sockets.c
index 75faa0f..128c721 100644
--- a/sockets.c
+++ b/sockets.c
@@ -806,7 +806,9 @@ static struct unix_sk_info *find_unix_sk(int id)
 	struct file_desc *d;
 
 	d = find_file_desc_raw(FDINFO_UNIXSK, id);
-	return container_of(d, struct unix_sk_info, d);
+	if (d)
+		return container_of(d, struct unix_sk_info, d);
+	return NULL;
 }
 
 struct sk_packet {
-- 
1.7.7.6



More information about the CRIU mailing list