unsigned instance;
 
        fsa_dev_ptr = dev->fsa_dev;
+       if (!fsa_dev_ptr)
+               return -ENOMEM;
        instance = dev->scsi_host_ptr->unique_id;
 
        if (!(fibptr = aac_fib_alloc(dev)))
        struct scsi_cmnd *cmd;
        struct scsi_device *sdev = scsicmd->device;
        int active = 0;
+       struct aac_dev *aac;
        unsigned long flags;
 
        /*
        if (active)
                return SCSI_MLQUEUE_DEVICE_BUSY;
 
+       aac = (struct aac_dev *)scsicmd->device->host->hostdata;
        /*
         *      Allocate and initialize a Fib
         */
-       if (!(cmd_fibcontext = 
-           aac_fib_alloc((struct aac_dev *)scsicmd->device->host->hostdata)))
+       if (!(cmd_fibcontext = aac_fib_alloc(aac)))
                return SCSI_MLQUEUE_HOST_BUSY;
 
        aac_fib_init(cmd_fibcontext);
        struct aac_dev *dev = (struct aac_dev *)host->hostdata;
        struct fsa_dev_info *fsa_dev_ptr = dev->fsa_dev;
        
+       if (fsa_dev_ptr == NULL)
+               return -1;
        /*
         *      If the bus, id or lun is out of range, return fail
         *      Test does not apply to ID 16, the pseudo id for the controller
        struct fsa_dev_info *fsa_dev_ptr;
 
        fsa_dev_ptr = dev->fsa_dev;
+       if (!fsa_dev_ptr)
+               return -ENODEV;
        if (copy_from_user(&qd, arg, sizeof (struct aac_query_disk)))
                return -EFAULT;
        if (qd.cnum == -1)
        struct fsa_dev_info *fsa_dev_ptr;
 
        fsa_dev_ptr = dev->fsa_dev;
+       if (!fsa_dev_ptr)
+               return -ENODEV;
+       if (!fsa_dev_ptr)
+               return -ENODEV;
 
        if (copy_from_user(&dd, arg, sizeof (struct aac_delete_disk)))
                return -EFAULT;