Skip to content

Commit ffa4d72

Browse files
kaberDavid S. Miller
authored andcommitted
[NETLINK]: don't reinitialize callback mutex
Don't reinitialize the callback mutex the netlink_kernel_create caller handed in, it is supposed to already be initialized and could already be held by someone. Signed-off-by: Patrick McHardy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6313c1e commit ffa4d72

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/netlink/af_netlink.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,12 @@ static int __netlink_create(struct socket *sock, struct mutex *cb_mutex,
388388
sock_init_data(sock, sk);
389389

390390
nlk = nlk_sk(sk);
391-
nlk->cb_mutex = cb_mutex ? : &nlk->cb_def_mutex;
392-
mutex_init(nlk->cb_mutex);
391+
if (cb_mutex)
392+
nlk->cb_mutex = cb_mutex;
393+
else {
394+
nlk->cb_mutex = &nlk->cb_def_mutex;
395+
mutex_init(nlk->cb_mutex);
396+
}
393397
init_waitqueue_head(&nlk->wait);
394398

395399
sk->sk_destruct = netlink_sock_destruct;

0 commit comments

Comments
 (0)