]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
[SCSI] zfcp: Fix warnings from smatch
authorChristof Schmitt <christof.schmitt@de.ibm.com>
Wed, 17 Feb 2010 10:18:53 +0000 (11:18 +0100)
committerJames Bottomley <James.Bottomley@suse.de>
Wed, 17 Feb 2010 23:46:24 +0000 (17:46 -0600)
The smatch tool from http://repo.or.cz/w/smatch.git warns about this:

drivers/s390/scsi/zfcp_scsi.c +64 zfcp_scsi_command_fail(5) warn: variable dereferenced before check 'scpnt->device'
drivers/s390/scsi/zfcp_scsi.c +64 zfcp_scsi_command_fail(5) warn: variable dereferenced before check 'scpnt->device->host'
drivers/s390/scsi/zfcp_scsi.c +93 zfcp_scsi_queuecommand(23) warn: variable dereferenced before check 'unit'

Fix the first two warnings by removing the checks for scpnt->device
and -> host: As long as the SCSI command exists, there is also a
scsi_device and a Scsi_Host.

Fix the last warning by removing the BUG_ON checks in
zfcp_scsi_queuecommand, they are leftovers from previous paranoia
about wrong pointers between data structures.

Reviewed-by: Swen Schillig <swen@vnet.ibm.com>
Signed-off-by: Christof Schmitt <christof.schmitt@de.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/s390/scsi/zfcp_scsi.c

index e1e56f52311617c62e459226684de6123a040fde..1fce8a49fc6053a1bd2e2407fadfa85e261120eb 100644 (file)
@@ -60,10 +60,9 @@ static void zfcp_scsi_command_fail(struct scsi_cmnd *scpnt, int result)
 {
        struct zfcp_adapter *adapter =
                (struct zfcp_adapter *) scpnt->device->host->hostdata[0];
+
        set_host_byte(scpnt, result);
-       if ((scpnt->device != NULL) && (scpnt->device->host != NULL))
-               zfcp_dbf_scsi_result("fail", 4, adapter->dbf, scpnt, NULL);
-       /* return directly */
+       zfcp_dbf_scsi_result("fail", 4, adapter->dbf, scpnt, NULL);
        scpnt->scsi_done(scpnt);
 }
 
@@ -87,14 +86,6 @@ static int zfcp_scsi_queuecommand(struct scsi_cmnd *scpnt,
        adapter = (struct zfcp_adapter *) scpnt->device->host->hostdata[0];
        unit = scpnt->device->hostdata;
 
-       BUG_ON(!adapter || (adapter != unit->port->adapter));
-       BUG_ON(!scpnt->scsi_done);
-
-       if (unlikely(!unit)) {
-               zfcp_scsi_command_fail(scpnt, DID_NO_CONNECT);
-               return 0;
-       }
-
        scsi_result = fc_remote_port_chkready(rport);
        if (unlikely(scsi_result)) {
                scpnt->result = scsi_result;