Skip to content

Commit 48b19b7

Browse files
philzjhmartinkpetersen
authored andcommitted
scsi: iscsi_tcp: Check that sock is valid before iscsi_set_param()
The validity of sock should be checked before assignment to avoid incorrect values. Commit 57569c3 ("scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()") introduced this change which may lead to inconsistent values of tcp_sw_conn->sendpage and conn->datadgst_en. Fix the issue by moving the position of the assignment. Fixes: 57569c3 ("scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()") Signed-off-by: Zhong Jinghua <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 85ade40 commit 48b19b7

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/scsi/iscsi_tcp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,13 +771,12 @@ static int iscsi_sw_tcp_conn_set_param(struct iscsi_cls_conn *cls_conn,
771771
iscsi_set_param(cls_conn, param, buf, buflen);
772772
break;
773773
case ISCSI_PARAM_DATADGST_EN:
774-
iscsi_set_param(cls_conn, param, buf, buflen);
775-
776774
mutex_lock(&tcp_sw_conn->sock_lock);
777775
if (!tcp_sw_conn->sock) {
778776
mutex_unlock(&tcp_sw_conn->sock_lock);
779777
return -ENOTCONN;
780778
}
779+
iscsi_set_param(cls_conn, param, buf, buflen);
781780
tcp_sw_conn->sendpage = conn->datadgst_en ?
782781
sock_no_sendpage : tcp_sw_conn->sock->ops->sendpage;
783782
mutex_unlock(&tcp_sw_conn->sock_lock);

0 commit comments

Comments
 (0)