Re: PATCH] scsi: stex: properly zero out the passthrough command structure

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

 



On Thu, Sep 08, 2022 at 02:16:33PM -0400, Linus Torvalds wrote:
> Sorry for bad message ID threading, but I don't have the original
> email from Greg in my email, just a link to it on lore..
> 
> I'd suggest perhaps a slightly bigger patch than just adding the memset().
> 
> Something like the attached?
> 
> Entirely untested, but it would seem to be the cleaner way to go about this. No?
> 
>             Linus

>  drivers/scsi/stex.c      | 17 +++++++++--------
>  include/scsi/scsi_cmnd.h |  2 +-
>  2 files changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
> index e6420f2127ce..8def242675ef 100644
> --- a/drivers/scsi/stex.c
> +++ b/drivers/scsi/stex.c
> @@ -665,16 +665,17 @@ static int stex_queuecommand_lck(struct scsi_cmnd *cmd)
>  		return 0;
>  	case PASSTHRU_CMD:
>  		if (cmd->cmnd[1] == PASSTHRU_GET_DRVVER) {
> -			struct st_drvver ver;
> +			const struct st_drvver ver = {
> +				.major = ST_VER_MAJOR,
> +				.minor = ST_VER_MINOR,
> +				.oem = ST_OEM,
> +				.build = ST_BUILD_VER,
> +				.signature[0] = PASSTHRU_SIGNATURE,
> +				.console_id = host->max_id - 1,
> +				.host_no = hba->host->host_no,
> +			};
>  			size_t cp_len = sizeof(ver);
>  
> -			ver.major = ST_VER_MAJOR;
> -			ver.minor = ST_VER_MINOR;
> -			ver.oem = ST_OEM;
> -			ver.build = ST_BUILD_VER;
> -			ver.signature[0] = PASSTHRU_SIGNATURE;
> -			ver.console_id = host->max_id - 1;
> -			ver.host_no = hba->host->host_no;
>  			cp_len = scsi_sg_copy_from_buffer(cmd, &ver, cp_len);
>  			if (sizeof(ver) == cp_len)
>  				cmd->result = DID_OK << 16;
> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> index bac55decf900..7d3622db38ed 100644
> --- a/include/scsi/scsi_cmnd.h
> +++ b/include/scsi/scsi_cmnd.h
> @@ -201,7 +201,7 @@ static inline unsigned int scsi_get_resid(struct scsi_cmnd *cmd)
>  	for_each_sg(scsi_sglist(cmd), sg, nseg, __i)
>  
>  static inline int scsi_sg_copy_from_buffer(struct scsi_cmnd *cmd,
> -					   void *buf, int buflen)
> +					   const void *buf, int buflen)
>  {
>  	return sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd),
>  				   buf, buflen);


Sure, this looks a bit "nicer" than just the memset, let me resend this
as a v2.

thanks,

greg k-h



[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