Skip to contentSkip to conversation

scsi: cxgb4i: Add support for iSCSI segmentation offload

bug report [email protected] 2 participants 3 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:2158 cxgbi_conn_init_pdu()
warn: variable dereferenced before check 'tdata' (see line 2150)

drivers/scsi/cxgbi/libcxgbi.c
2149 struct cxgbi_task_data *tdata = iscsi_task_cxgbi_data(task);

  2150		struct sk_buff *skb = tdata->skb;
                                      ^^^^^^^^^^

The old code doesn't check for NULL.

2151 struct scsi_cmnd *sc = task->sc;
2152 u32 expected_count, expected_offset;
2153 u32 datalen = count, dlimit = 0;
2154 u32 i, padlen = iscsi_padding(count);
2155 struct page *pg;
2156 int err;
2157

  2158		if (!tcp_task || !tdata || tcp_task->dd_data != tdata) {
                                 ^^^^^^

The new check is too late.

2159 pr_err("task 0x%p,0x%p, tcp_task 0x%p, tdata 0x%p/0x%p.\n",
2160 task, task->sc, tcp_task,

regards,
dan carpenter

#1 lore raw
Quoted 11 lines · On Fri, Jul 10, 2020 at 05:17:29PM +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:2158 cxgbi_conn_init_pdu()
warn: variable dereferenced before check 'tdata' (see line 2150)

Same issue in cxgbi_conn_xmit_pdu() as well.

drivers/scsi/cxgbi/libcxgbi.c:2374 cxgbi_conn_xmit_pdu() warn: variable dereferenced before check 'tdata' (see line 2368)

regards,
dan carpenter

#2 lore raw
Quoted 9 lines · Dan Carpenter
Quoted 8 lines · On Fri, Jul 10, 2020 at 05:17:29PM +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:

Quoted 7 lines
Quoted 3 lines

drivers/scsi/cxgbi/libcxgbi.c:2158 cxgbi_conn_init_pdu()
warn: variable dereferenced before check 'tdata' (see line 2150)

Same issue in cxgbi_conn_xmit_pdu() as well.

drivers/scsi/cxgbi/libcxgbi.c:2374 cxgbi_conn_xmit_pdu() warn: variable dereferenced before check 'tdata' (see line 2368)

Patch is already posted for this issue
https://patchwork.kernel.org/patch/11654403/