RE: [PATCH 2/2] replace sizeof sense_buffer with SCSI_SENSE_BUFFERSIZE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ACK on ips, aacraid and dpt_i2o bits. Cursory inspection of other bits as well. Thanks Fujita, looks good!

Will do a 'min()' cleanup on aacraid once patch propagates into scsi-misc-2.6

Sincerely -- Mark Salyzyn

cur*so*ry - adjective
        going rapidly over something, without noticing details; hasty; superficial. spedd reeding

. . .
> o This is a 'grep and replace' style patch but cleans up dpt_i2o a bit
> as by permission of Mark (I use min macro).
>
> o The previous version overlooked some sizeof sense_buffer lines in
> aacraid and qla4xxx.
. . .
> diff --git a/drivers/scsi/aacraid/aachba.c
> b/drivers/scsi/aacraid/aachba.c
> index 62d9516..aadedbd 100644
> --- a/drivers/scsi/aacraid/aachba.c
> +++ b/drivers/scsi/aacraid/aachba.c
> @@ -912,8 +912,8 @@ static int aac_bounds_32(struct aac_dev *
> dev, struct scsi_cmnd * cmd, u64 lba)
>                             ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
>                             0, 0);
>                 memcpy(cmd->sense_buffer,
> &dev->fsa_dev[cid].sense_data,
> -                 (sizeof(dev->fsa_dev[cid].sense_data) >
> sizeof(cmd->sense_buffer))
> -                   ? sizeof(cmd->sense_buffer)
> +                 (sizeof(dev->fsa_dev[cid].sense_data) >
> SCSI_SENSE_BUFFERSIZE)
> +                   ? SCSI_SENSE_BUFFERSIZE
>                     : sizeof(dev->fsa_dev[cid].sense_data));
>                 cmd->scsi_done(cmd);
>                 return 1;
> @@ -1525,8 +1525,8 @@ static void io_callback(void *context,
> struct fib * fibptr)
>
> ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
>                                     0, 0);
>                 memcpy(scsicmd->sense_buffer,
> &dev->fsa_dev[cid].sense_data,
> -                 (sizeof(dev->fsa_dev[cid].sense_data) >
> sizeof(scsicmd->sense_buffer))
> -                   ? sizeof(scsicmd->sense_buffer)
> +                 (sizeof(dev->fsa_dev[cid].sense_data) >
> SCSI_SENSE_BUFFERSIZE)
> +                   ? SCSI_SENSE_BUFFERSIZE
>                     : sizeof(dev->fsa_dev[cid].sense_data));
>         }
>         aac_fib_complete(fibptr);
> @@ -1739,8 +1739,8 @@ static void synchronize_callback(void
> *context, struct fib *fibptr)
>
> ASENCODE_INTERNAL_TARGET_FAILURE, 0, 0,
>                                     0, 0);
>                 memcpy(cmd->sense_buffer,
> &dev->fsa_dev[cid].sense_data,
> -                 min(sizeof(dev->fsa_dev[cid].sense_data),
> -                         sizeof(cmd->sense_buffer)));
> +                      min_t(size_t,
> sizeof(dev->fsa_dev[cid].sense_data),
> +                            SCSI_SENSE_BUFFERSIZE));
>         }
>
>         aac_fib_complete(fibptr);
> @@ -1949,8 +1949,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
>                             SENCODE_INVALID_COMMAND,
>                             ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
>                 memcpy(scsicmd->sense_buffer,
> &dev->fsa_dev[cid].sense_data,
> -                 (sizeof(dev->fsa_dev[cid].sense_data) >
> sizeof(scsicmd->sense_buffer))
> -                   ? sizeof(scsicmd->sense_buffer)
> +                 (sizeof(dev->fsa_dev[cid].sense_data) >
> SCSI_SENSE_BUFFERSIZE)
> +                   ? SCSI_SENSE_BUFFERSIZE
>                     : sizeof(dev->fsa_dev[cid].sense_data));
>                 scsicmd->scsi_done(scsicmd);
>                 return 0;
> @@ -2002,8 +2002,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
>                                 memcpy(scsicmd->sense_buffer,
>                                   &dev->fsa_dev[cid].sense_data,
>
> (sizeof(dev->fsa_dev[cid].sense_data) >
> -                                   sizeof(scsicmd->sense_buffer))
> -                                      ? sizeof(scsicmd->sense_buffer)
> +                                   SCSI_SENSE_BUFFERSIZE)
> +                                      ? SCSI_SENSE_BUFFERSIZE
>                                        :
> sizeof(dev->fsa_dev[cid].sense_data));
>                         }
>                         scsicmd->scsi_done(scsicmd);
> @@ -2259,8 +2259,8 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
>                                 ILLEGAL_REQUEST,
> SENCODE_INVALID_COMMAND,
>                                 ASENCODE_INVALID_COMMAND, 0, 0, 0, 0);
>                         memcpy(scsicmd->sense_buffer,
> &dev->fsa_dev[cid].sense_data,
> -
> (sizeof(dev->fsa_dev[cid].sense_data) > sizeof(scsicmd->sense_buffer))
> -                           ? sizeof(scsicmd->sense_buffer)
> +
> (sizeof(dev->fsa_dev[cid].sense_data) > SCSI_SENSE_BUFFERSIZE)
> +                           ? SCSI_SENSE_BUFFERSIZE
>                             : sizeof(dev->fsa_dev[cid].sense_data));
>                         scsicmd->scsi_done(scsicmd);
>                         return 0;
> @@ -2422,8 +2422,8 @@ static void aac_srb_callback(void
> *context, struct fib * fibptr)
>                 int len;
>                 printk(KERN_WARNING "aac_srb_callback: srb
> failed, status = %d\n", le32_to_cpu(srbreply->status));
>                 len = (le32_to_cpu(srbreply->sense_data_size) >
> -                               sizeof(scsicmd->sense_buffer)) ?
> -                               sizeof(scsicmd->sense_buffer) :
> +                               SCSI_SENSE_BUFFERSIZE) ?
> +                               SCSI_SENSE_BUFFERSIZE :
>
> le32_to_cpu(srbreply->sense_data_size);
>                 scsicmd->result = DID_ERROR << 16 |
> COMMAND_COMPLETE << 8 | SAM_STAT_CHECK_CONDITION;
>                 memcpy(scsicmd->sense_buffer,
> srbreply->sense_data, len);
> @@ -2528,8 +2528,8 @@ static void aac_srb_callback(void
> *context, struct fib * fibptr)
>                 int len;
>                 scsicmd->result |= SAM_STAT_CHECK_CONDITION;
>                 len = (le32_to_cpu(srbreply->sense_data_size) >
> -                               sizeof(scsicmd->sense_buffer)) ?
> -                               sizeof(scsicmd->sense_buffer) :
> +                               SCSI_SENSE_BUFFERSIZE) ?
> +                               SCSI_SENSE_BUFFERSIZE :
>
> le32_to_cpu(srbreply->sense_data_size);
>  #ifdef AAC_DETAILED_STATUS_INFO
>                 printk(KERN_WARNING "aac_srb_callback: check
> condition, status = %d len=%d\n",
. . .
> diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
> index b31d1c9..577b34c 100644
> --- a/drivers/scsi/dpt_i2o.c
> +++ b/drivers/scsi/dpt_i2o.c
> @@ -2296,9 +2296,8 @@ static s32 adpt_i2o_to_scsi(void
> __iomem *reply, struct scsi_cmnd* cmd)
>
>                 // copy over the request sense data if it was a check
>                 // condition status
> -               if(dev_status == 0x02 /*CHECK_CONDITION*/) {
> -                       u32 len = sizeof(cmd->sense_buffer);
> -                       len = (len > 40) ?  40 : len;
> +               if (dev_status == 0x02 /*CHECK_CONDITION*/) {
> +                       u32 len = min(SCSI_SENSE_BUFFERSIZE, 40);
>                         // Copy over the sense data
>                         memcpy_fromio(cmd->sense_buffer,
> (reply+28) , len);
>                         if(cmd->sense_buffer[0] == 0x70 /*
> class 7 */ &&
. . .
> diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
> index b1b2295..f44993f 100644
> --- a/drivers/scsi/ips.c
> +++ b/drivers/scsi/ips.c
> @@ -3433,13 +3433,11 @@ ips_map_status(ips_ha_t * ha,
> ips_scb_t * scb, ips_stat_t * sp)
>
> (IPS_DCDB_TABLE_TAPE *) & scb->dcdb;
>
> memcpy(scb->scsi_cmd->sense_buffer,
>                                                tapeDCDB->sense_info,
> -                                              sizeof (scb->scsi_cmd->
> -                                                      sense_buffer));
> +
> SCSI_SENSE_BUFFERSIZE);
>                                 } else {
>
> memcpy(scb->scsi_cmd->sense_buffer,
>                                                scb->dcdb.sense_info,
> -                                              sizeof (scb->scsi_cmd->
> -                                                      sense_buffer));
> +
> SCSI_SENSE_BUFFERSIZE);
>                                 }
>                                 device_error = 2;       /*
> check condition */
>                         }
. . .
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux