Skip to content

Commit e9dd5fd

Browse files
Alexander Aringteigland
authored andcommitted
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 <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent 6f0b0b5 commit e9dd5fd

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

fs/dlm/lowcomms.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,9 @@ int dlm_lowcomms_addr(int nodeid, struct sockaddr_storage *addr, int len)
472472
/* Data available on socket or listen socket received a connect */
473473
static void lowcomms_data_ready(struct sock *sk)
474474
{
475-
struct connection *con;
475+
struct connection *con = sock2con(sk);
476476

477-
con = sock2con(sk);
478-
if (con && !test_and_set_bit(CF_READ_PENDING, &con->flags))
477+
if (!test_and_set_bit(CF_READ_PENDING, &con->flags))
479478
queue_work(recv_workqueue, &con->rwork);
480479
}
481480

@@ -486,11 +485,7 @@ static void lowcomms_listen_data_ready(struct sock *sk)
486485

487486
static void lowcomms_write_space(struct sock *sk)
488487
{
489-
struct connection *con;
490-
491-
con = sock2con(sk);
492-
if (!con)
493-
return;
488+
struct connection *con = sock2con(sk);
494489

495490
if (!test_and_set_bit(CF_CONNECTED, &con->flags)) {
496491
log_print("connected to node %d", con->nodeid);
@@ -573,14 +568,10 @@ int dlm_lowcomms_nodes_set_mark(int nodeid, unsigned int mark)
573568

574569
static void lowcomms_error_report(struct sock *sk)
575570
{
576-
struct connection *con;
571+
struct connection *con = sock2con(sk);
577572
void (*orig_report)(struct sock *) = NULL;
578573
struct inet_sock *inet;
579574

580-
con = sock2con(sk);
581-
if (con == NULL)
582-
goto out;
583-
584575
orig_report = listen_sock.sk_error_report;
585576

586577
inet = inet_sk(sk);

0 commit comments

Comments
 (0)