summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2019-06-04 23:06:02 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2019-06-04 23:06:02 -0700
commitc53f4c9b5b07d5b6d3847ad5b9d2269a0dcfb4b6 (patch)
treeee8f3d2c0f9ffa67020cbc664e3c83783bdca585 /net
parentecf5d04a091c441793b589e8406357884ee54d58 (diff)
parentb924e5efad9c9e56633f3c3d2ddcce288070af27 (diff)
Merge "net: sockev: avoid races between sockev and socket_close"
Diffstat (limited to 'net')
-rw-r--r--net/core/sockev_nlmcast.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/net/core/sockev_nlmcast.c b/net/core/sockev_nlmcast.c
index 1e92c5632b97..0a8b0ed99356 100644
--- a/net/core/sockev_nlmcast.c
+++ b/net/core/sockev_nlmcast.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2015, 2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2015, 2018-2019 The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -73,11 +73,13 @@ static int sockev_client_cb(struct notifier_block *nb,
sock = (struct socket *)data;
if (!socknlmsgsk || !sock)
- goto done;
+ goto sk_null;
sk = sock->sk;
if (!sk)
- goto done;
+ goto sk_null;
+
+ sock_hold(sk);
if (sk->sk_family != AF_INET && sk->sk_family != AF_INET6)
goto done;
@@ -108,6 +110,8 @@ static int sockev_client_cb(struct notifier_block *nb,
smsg->skflags = sk->sk_flags;
nlmsg_notify(socknlmsgsk, skb, 0, SKNLGRP_SOCKEV, 0, GFP_KERNEL);
done:
+ sock_put(sk);
+sk_null:
return 0;
}