Re: [PATCH] scsi: Fix printing of variable length commands

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

 



On 01/19/2010 01:03 AM, Martin K. Petersen wrote:
> 
> The MAINTENANCE IN array is incorrectly used when decoding variable
> length commands.  Use the right array.
> 
> Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
> 
> ---
> 
> diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
> index 9129bcf..db68e3b 100644
> --- a/drivers/scsi/constants.c
> +++ b/drivers/scsi/constants.c
> @@ -219,7 +219,7 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
>  			break;
>  		}
>  		sa = (cdbp[8] << 8) + cdbp[9];
> -		name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa);
> +		name = get_sa_name(variable_length_arr, VARIABLE_LENGTH_SZ, sa);
>  		if (name) {
>  			printk("%s", name);
>  			if ((cdb_len > 0) && (len != cdb_len))
> --

If you are already at it could you also add the things that bothered me? I did stare
at this function before, but did not see the bug you are fixing, thanks.
(Did see other less important stuff)

(Below also includes your change)
---
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 9129bcf..6c3c31e 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -218,19 +218,16 @@ static void print_opcode_name(unsigned char * cdbp, int cdb_len)
 			       "len=%d ext_len=%d", len, cdb_len);
 			break;
 		}
-		sa = (cdbp[8] << 8) + cdbp[9];
-		name = get_sa_name(maint_in_arr, MAINT_IN_SZ, sa);
+		sa = be16_to_cpu(
+			((struct scsi_varlen_cdb_hdr *)cdbp)->service_action);
+		name = get_sa_name(variable_length_arr, VARIABLE_LENGTH_SZ, sa);
 		if (name) {
 			printk("%s", name);
-			if ((cdb_len > 0) && (len != cdb_len))
-				printk(", in_cdb_len=%d, ext_len=%d",
-				       len, cdb_len);
 		} else {
 			printk("cdb[0]=0x%x, sa=0x%x", cdb0, sa);
-			if ((cdb_len > 0) && (len != cdb_len))
-				printk(", in_cdb_len=%d, ext_len=%d",
-				       len, cdb_len);
 		}
+		if ((cdb_len > 0) && (len != cdb_len))
+			printk(", in_cdb_len=%d, ext_len=%d", len, cdb_len);
 		break;
 	case MAINTENANCE_IN:
 		sa = cdbp[1] & 0x1f;
--
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