public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Sakthivel.SaravananKamalRaju@pmcs.com
Cc: linux-scsi@vger.kernel.org
Subject: re: [SCSI] pm80xx: NCQ error handling changes
Date: Wed, 8 May 2013 22:57:16 +0300	[thread overview]
Message-ID: <20130508195716.GA14142@elgon.mountain> (raw)

Hello Sakthivel K,

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

The patch 1cde970c1025: "[SCSI] pm80xx: NCQ error handling changes"
from Mar 19, 2013, leads to the following Smatch complaint:

drivers/scsi/pm8001/pm8001_hwi.c:4393 pm8001_chip_sata_req()
	 warn: variable dereferenced before check 'pm8001_ha_dev' (see line 4362)

drivers/scsi/pm8001/pm8001_hwi.c
  4361		sata_cmd.tag = cpu_to_le32(tag);
  4362		sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id);
                                                 ^^^^^^^^^^^^^
Old dereference.

  4363		sata_cmd.data_len = cpu_to_le32(task->total_xfer_len);
  4364		sata_cmd.ncqtag_atap_dir_m =
  4365			cpu_to_le32(((ncg_tag & 0xff)<<16)|((ATAP & 0x3f) << 10) | dir);
  4366		sata_cmd.sata_fis = task->ata_task.fis;
  4367		if (likely(!task->ata_task.device_control_reg_update))
  4368			sata_cmd.sata_fis.flags |= 0x80;/* C=1: update ATA cmd reg */
  4369		sata_cmd.sata_fis.flags &= 0xF0;/* PM_PORT field shall be 0 */
  4370		/* fill in PRD (scatter/gather) table, if any */
  4371		if (task->num_scatter > 1) {
  4372			pm8001_chip_make_sg(task->scatter, ccb->n_elem, ccb->buf_prd);
  4373			phys_addr = ccb->ccb_dma_handle +
  4374					offsetof(struct pm8001_ccb_info, buf_prd[0]);
  4375			sata_cmd.addr_low = lower_32_bits(phys_addr);
  4376			sata_cmd.addr_high = upper_32_bits(phys_addr);
  4377			sata_cmd.esgl = cpu_to_le32(1 << 31);
  4378		} else if (task->num_scatter == 1) {
  4379			u64 dma_addr = sg_dma_address(task->scatter);
  4380			sata_cmd.addr_low = lower_32_bits(dma_addr);
  4381			sata_cmd.addr_high = upper_32_bits(dma_addr);
  4382			sata_cmd.len = cpu_to_le32(task->total_xfer_len);
  4383			sata_cmd.esgl = 0;
  4384		} else if (task->num_scatter == 0) {
  4385			sata_cmd.addr_low = 0;
  4386			sata_cmd.addr_high = 0;
  4387			sata_cmd.len = cpu_to_le32(task->total_xfer_len);
  4388			sata_cmd.esgl = 0;
  4389		}
  4390	
  4391		/* Check for read log for failed drive and return */
  4392		if (sata_cmd.sata_fis.command == 0x2f) {
  4393			if (pm8001_ha_dev && ((pm8001_ha_dev->id & NCQ_READ_LOG_FLAG) ||
                            ^^^^^^^^^^^^^
New check.  Probably this check is unneeded and can be removed.

  4394				(pm8001_ha_dev->id & NCQ_ABORT_ALL_FLAG) ||
  4395				(pm8001_ha_dev->id & NCQ_2ND_RLE_FLAG))) {

regards,
dan carpenter

                 reply	other threads:[~2013-05-08 19:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130508195716.GA14142@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=Sakthivel.SaravananKamalRaju@pmcs.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox