Skip to content

Commit 0c9f151

Browse files
Ursula Braundavem330
authored andcommitted
smc: improve smc_clc_send_decline() error handling
Let smc_clc_send_decline() return with an error, if the amount sent is smaller than the length of an smc decline message. Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a8ae890 commit 0c9f151

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

net/smc/af_smc.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ static int smc_connect_rdma(struct smc_sock *smc)
520520
smc->use_fallback = true;
521521
if (reason_code && (reason_code != SMC_CLC_DECL_REPLY)) {
522522
rc = smc_clc_send_decline(smc, reason_code);
523-
if (rc < sizeof(struct smc_clc_msg_decline))
523+
if (rc < 0)
524524
goto out_err;
525525
}
526526
goto out_connected;
@@ -879,11 +879,9 @@ static void smc_listen_work(struct work_struct *work)
879879
}
880880
/* QP confirmation over RoCE fabric */
881881
reason_code = smc_serv_conf_first_link(new_smc);
882-
if (reason_code < 0) {
882+
if (reason_code < 0)
883883
/* peer is not aware of a problem */
884-
rc = reason_code;
885884
goto out_err_unlock;
886-
}
887885
if (reason_code > 0)
888886
goto decline_rdma_unlock;
889887
}
@@ -916,8 +914,7 @@ static void smc_listen_work(struct work_struct *work)
916914
smc_conn_free(&new_smc->conn);
917915
new_smc->use_fallback = true;
918916
if (reason_code && (reason_code != SMC_CLC_DECL_REPLY)) {
919-
rc = smc_clc_send_decline(new_smc, reason_code);
920-
if (rc < sizeof(struct smc_clc_msg_decline))
917+
if (smc_clc_send_decline(new_smc, reason_code) < 0)
921918
goto out_err;
922919
}
923920
goto out_connected;

net/smc/smc_clc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info)
133133
smc->sk.sk_err = EPROTO;
134134
if (len < 0)
135135
smc->sk.sk_err = -len;
136-
return len;
136+
return sock_error(&smc->sk);
137137
}
138138

139139
/* send CLC PROPOSAL message across internal TCP socket */

0 commit comments

Comments
 (0)