From e9dd5fd849f1ac125919a79eb4be66f078dd7f51 Mon Sep 17 00:00:00 2001 From: Alexander Aring Date: Thu, 17 Nov 2022 17:11:54 -0500 Subject: fs: dlm: use sock2con without checking null This patch removes null checks on private data for sockets. If we have a null dereference there we having a bug in our implementation that such callback occurs in this state. Signed-off-by: Alexander Aring Signed-off-by: David Teigland --- fs/dlm/lowcomms.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'fs/dlm') diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c index ed3cd3757199..677e31144ca0 100644 --- a/fs/dlm/lowcomms.c +++ b/fs/dlm/lowcomms.c @@ -472,10 +472,9 @@ int dlm_lowcomms_addr(int nodeid, struct sockaddr_storage *addr, int len) /* Data available on socket or listen socket received a connect */ static void lowcomms_data_ready(struct sock *sk) { - struct connection *con; + struct connection *con = sock2con(sk); - con = sock2con(sk); - if (con && !test_and_set_bit(CF_READ_PENDING, &con->flags)) + if (!test_and_set_bit(CF_READ_PENDING, &con->flags)) queue_work(recv_workqueue, &con->rwork); } @@ -486,11 +485,7 @@ static void lowcomms_listen_data_ready(struct sock *sk) static void lowcomms_write_space(struct sock *sk) { - struct connection *con; - - con = sock2con(sk); - if (!con) - return; + struct connection *con = sock2con(sk); if (!test_and_set_bit(CF_CONNECTED, &con->flags)) { log_print("connected to node %d", con->nodeid); @@ -573,14 +568,10 @@ int dlm_lowcomms_nodes_set_mark(int nodeid, unsigned int mark) static void lowcomms_error_report(struct sock *sk) { - struct connection *con; + struct connection *con = sock2con(sk); void (*orig_report)(struct sock *) = NULL; struct inet_sock *inet; - con = sock2con(sk); - if (con == NULL) - goto out; - orig_report = listen_sock.sk_error_report; inet = inet_sk(sk); -- cgit v1.2.3