isert-scst: Resolve the parent container after checking it exists

The saved Cppcheck report warns in isert_send_completion_handler:

  iscsi-scst/kernel/isert-scst/iser_rdma.c:429: warning:
  Either the condition 'iscsi_req_pdu' is redundant or there is overflow
  in pointer subtraction. [nullPointerArithmeticRedundantCheck]

The parent request is optional, but container_of subtracts the member
offset before the NULL check. Resolve the parent container only after
confirming that the request exists and has a buffer. Preserve completion
handling for responses without a parent and for valid remote tags.
This commit is contained in:
Gleb Chesnokov
2026-10-21 13:20:12 +03:00
parent aadd0a457f
commit f480fc71ff
+7 -5
View File
@@ -427,14 +427,16 @@ static void isert_send_completion_handler(struct isert_wr *wr)
struct isert_cmnd *isert_pdu = wr->pdu;
struct iscsi_cmnd *iscsi_pdu = &isert_pdu->iscsi;
struct iscsi_cmnd *iscsi_req_pdu = iscsi_pdu->parent_req;
struct isert_cmnd *isert_req_pdu = container_of(iscsi_req_pdu,
struct isert_cmnd, iscsi);
TRACE_ENTRY();
if (iscsi_req_pdu && iscsi_req_pdu->bufflen &&
isert_req_pdu->is_rstag_valid)
isert_data_in_sent(iscsi_req_pdu);
if (iscsi_req_pdu && iscsi_req_pdu->bufflen) {
struct isert_cmnd *isert_req_pdu =
container_of(iscsi_req_pdu, struct isert_cmnd, iscsi);
if (isert_req_pdu->is_rstag_valid)
isert_data_in_sent(iscsi_req_pdu);
}
isert_pdu_sent(iscsi_pdu);