netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netlink: do not SIGSEGV when socket() fails
@ 2013-12-04 19:12 Shawn Landden
  2013-12-04 19:30 ` Arturo Borrero Gonzalez
  0 siblings, 1 reply; 6+ messages in thread
From: Shawn Landden @ 2013-12-04 19:12 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Shawn Landden

---
 src/netlink.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/netlink.c b/src/netlink.c
index 533634a..664487d 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -33,8 +33,11 @@ static struct mnl_socket *nf_sock;
 static void __init netlink_open_sock(void)
 {
 	nf_sock = mnl_socket_open(NETLINK_NETFILTER);
-	if (nf_sock == NULL)
+	if (nf_sock == NULL) {
+                fprintf(fdopen(STDERR_FILENO, "a"), "Could not open AF_NETLINK socket: %s\n",
+                                        strerror(errno));
 		memory_allocation_error();
+        }
 
 	fcntl(mnl_socket_get_fd(nf_sock), F_SETFL, O_NONBLOCK);
 	mnl_batch_init();
@@ -42,7 +45,8 @@ static void __init netlink_open_sock(void)
 
 static void __exit netlink_close_sock(void)
 {
-	mnl_socket_close(nf_sock);
+        if (nf_sock)
+                mnl_socket_close(nf_sock);
 }
 
 int netlink_io_error(struct netlink_ctx *ctx, const struct location *loc,
-- 
1.8.5.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-12-05  9:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-04 19:12 [PATCH] netlink: do not SIGSEGV when socket() fails Shawn Landden
2013-12-04 19:30 ` Arturo Borrero Gonzalez
2013-12-04 20:01   ` [nftables PATCH] " Shawn Landden
2013-12-04 20:30     ` Florian Westphal
2013-12-05  3:18       ` [PATCH] " Shawn Landden
2013-12-05  9:03         ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).