Skip to contentSkip to conversation

scsi: cxgb4i: Add support for iSCSI segmentation offload

bug report [email protected] 2 participants 2 messages Jul 10, 2020 – Jul 13, 2020 SCSI

lore
Share & tools
lore
#0 lore raw

Hello Varun Prakash,

This is a semi-automatic email about new static checker warnings.

The patch e33c2482289b: "scsi: cxgb4i: Add support for iSCSI segmentation offload" from Jun 29, 2020, leads to the following Smatch complaint:

drivers/scsi/cxgbi/libcxgbi.c:1892 cxgbi_conn_alloc_pdu()
warn: variable dereferenced before check 'cconn' (see line 1891)

drivers/scsi/cxgbi/libcxgbi.c
1890 struct cxgbi_conn *cconn = tcp_conn->dd_data;

  1891		struct cxgbi_device *cdev = cconn->chba->cdev;
                                            ^^^^^^^^^^^

Unchecked dereference in old code.

  1892		struct cxgbi_sock *csk = (cconn && cconn->cep) ? cconn->cep->csk : NULL;
                                          ^^^^^

New code adds a check for NULL but it's too late.

  1893		struct iscsi_tcp_task *tcp_task = task->dd_data;
  1894		struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);

regards,
dan carpenter

#1 lore raw
Quoted 13 lines · On Fri, Jul 10, 2020 at 05:14:54PM +0300, [email protected] wrote:

Hello Varun Prakash,

This is a semi-automatic email about new static checker warnings.

The patch e33c2482289b: "scsi: cxgb4i: Add support for iSCSI segmentation offload" from Jun 29, 2020, leads to the following Smatch complaint:

drivers/scsi/cxgbi/libcxgbi.c:1892 cxgbi_conn_alloc_pdu()
warn: variable dereferenced before check 'cconn' (see line 1891)

drivers/scsi/cxgbi/libcxgbi.c
1890 struct cxgbi_conn *cconn = tcp_conn->dd_data;

Quoted 7 lines
  1891		struct cxgbi_device *cdev = cconn->chba->cdev;
                                            ^^^^^^^^^^^

Unchecked dereference in old code.

  1892		struct cxgbi_sock *csk = (cconn && cconn->cep) ? cconn->cep->csk : NULL;
                                          ^^^^^

New code adds a check for NULL but it's too late.

cconn will never be NULL, I will post a patch to remove this NULL check.

Quoted 3 lines
  1893		struct iscsi_tcp_task *tcp_task = task->dd_data;
  1894		struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);