Skip to contentSkip to conversation

ipr: Increase max concurrent oustanding commands

SCSI Dan Carpenter 2 participants 2 messages Feb 23, 2015 SCSI

lore
Share & tools
lore
#0 lore raw

Hello Brian King,

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

The patch 89aad4283173: "[SCSI] ipr: Increase max concurrent oustanding commands" from Mar 14, 2012, leads to the following Smatch complaint:

drivers/scsi/ipr.c:9038 ipr_alloc_cmd_blks()

	 error: we previously assumed 'ioa_cfg->ipr_cmnd_list' could be null (see line 9037)

drivers/scsi/ipr.c
9036

  9037		if (!ioa_cfg->ipr_cmnd_list || !ioa_cfg->ipr_cmnd_list_dma) {
                     ^^^^^^^^^^^^^^^^^^^^^^

This can be NULL.

  9038			ipr_free_cmd_blks(ioa_cfg);
                                          ^^^^^^^

But we dereference it unconditionally inside the ipr_free_cmd_blks() function when we check: "if (ioa_cfg->ipr_cmnd_list[i])". These kinds of magic free everything functions are almost always buggy but Smatch missed this bug initialy and I had to update it. I'll push the Smatch change later this week. It requires the cross function database to trigger this warning.

9039 return -ENOMEM;
9040 }

regards,
dan carpenter

#1 lore raw
Quoted 17 lines · Dan Carpenter

Hello Brian King,

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

The patch 89aad4283173: "[SCSI] ipr: Increase max concurrent oustanding commands" from Mar 14, 2012, leads to the following Smatch complaint:

drivers/scsi/ipr.c:9038 ipr_alloc_cmd_blks()

	 error: we previously assumed 'ioa_cfg->ipr_cmnd_list' could be null (see line 9037)

drivers/scsi/ipr.c
9036

  9037		if (!ioa_cfg->ipr_cmnd_list || !ioa_cfg->ipr_cmnd_list_dma) {
                     ^^^^^^^^^^^^^^^^^^^^^^

This can be NULL.

Quoted 8 lines
  9038			ipr_free_cmd_blks(ioa_cfg);
                                          ^^^^^^^

But we dereference it unconditionally inside the ipr_free_cmd_blks() function when we check: "if (ioa_cfg->ipr_cmnd_list[i])". These kinds of magic free everything functions are almost always buggy but Smatch missed this bug initialy and I had to update it. I'll push the Smatch change later this week. It requires the cross function database to trigger this warning.

Thanks Dan. I'll queue up a fix for this one.

-Brian

Signature · 3 lines
Brian King
Power Linux I/O
IBM Linux Technology Center