diff mbox series

scsi: qla2xxx: Fix an endian bug in fcpcmd_is_corrupted()

Message ID 20180908084227.xo4g5aekndokopus@kili.mountain (mailing list archive)
State Accepted
Headers show
Series scsi: qla2xxx: Fix an endian bug in fcpcmd_is_corrupted() | expand

Commit Message

Dan Carpenter Sept. 8, 2018, 8:42 a.m. UTC
We should first do the le16_to_cpu endian conversion and then apply
the FCP_CMD_LENGTH_MASK mask.

Fixes: 5f35509db179 ("qla2xxx: Terminate exchange if corrupted")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
I just happened to spot this when I was reviewing something unrelated.
I don't have the hardware to test it, so please review carefully.

Comments

Tran, Quinn Sept. 10, 2018, 5:46 p.m. UTC | #1
Dan,

It looks good.  Thanks.

Regards,
Quinn Tran
-----Original Message-----
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Saturday, September 8, 2018 at 1:42 AM
To: Dept-Eng QLA2xxx Upstream <qla2xxx-upstream@cavium.com>, "Tran, Quinn" <Quinn.Tran@cavium.com>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>, "Martin K. Petersen" <martin.petersen@oracle.com>, "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>, "Madhani, Himanshu" <Himanshu.Madhani@cavium.com>, "kernel-janitors@vger.kernel.org" <kernel-janitors@vger.kernel.org>
Subject: [PATCH] scsi: qla2xxx: Fix an endian bug in fcpcmd_is_corrupted()

    External Email
    
    We should first do the le16_to_cpu endian conversion and then apply
    the FCP_CMD_LENGTH_MASK mask.
    
    Fixes: 5f35509db179 ("qla2xxx: Terminate exchange if corrupted")
    Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
    ---
    I just happened to spot this when I was reviewing something unrelated.
    I don't have the hardware to test it, so please review carefully.
    
    diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h
    index fecf96f0225c..199d3ba1916d 100644
    --- a/drivers/scsi/qla2xxx/qla_target.h
    +++ b/drivers/scsi/qla2xxx/qla_target.h
    @@ -374,8 +374,8 @@ struct atio_from_isp {
     static inline int fcpcmd_is_corrupted(struct atio *atio)
     {
            if (atio->entry_type == ATIO_TYPE7 &&
    -           (le16_to_cpu(atio->attr_n_length & FCP_CMD_LENGTH_MASK) <
    -           FCP_CMD_LENGTH_MIN))
    +           ((le16_to_cpu(atio->attr_n_length) & FCP_CMD_LENGTH_MASK) <
    +            FCP_CMD_LENGTH_MIN))
                    return 1;
            else
                    return 0;
Madhani, Himanshu Sept. 10, 2018, 5:49 p.m. UTC | #2
> On Sep 8, 2018, at 1:42 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> External Email
> 
> We should first do the le16_to_cpu endian conversion and then apply
> the FCP_CMD_LENGTH_MASK mask.
> 
> Fixes: 5f35509db179 ("qla2xxx: Terminate exchange if corrupted")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> I just happened to spot this when I was reviewing something unrelated.
> I don't have the hardware to test it, so please review carefully.
> 
> diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h
> index fecf96f0225c..199d3ba1916d 100644
> --- a/drivers/scsi/qla2xxx/qla_target.h
> +++ b/drivers/scsi/qla2xxx/qla_target.h
> @@ -374,8 +374,8 @@ struct atio_from_isp {
> static inline int fcpcmd_is_corrupted(struct atio *atio)
> {
>        if (atio->entry_type == ATIO_TYPE7 &&
> -           (le16_to_cpu(atio->attr_n_length & FCP_CMD_LENGTH_MASK) <
> -           FCP_CMD_LENGTH_MIN))
> +           ((le16_to_cpu(atio->attr_n_length) & FCP_CMD_LENGTH_MASK) <
> +            FCP_CMD_LENGTH_MIN))
>                return 1;
>        else
>                return 0;

Acked-By: Himanshu Madhani <himanshu.madhani@cavium.com>

Thanks,
- Himanshu
Martin K. Petersen Sept. 12, 2018, 1:09 a.m. UTC | #3
Dan,

> We should first do the le16_to_cpu endian conversion and then apply
> the FCP_CMD_LENGTH_MASK mask.

Applied to 4.19/scsi-fixes, thank you!
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h
index fecf96f0225c..199d3ba1916d 100644
--- a/drivers/scsi/qla2xxx/qla_target.h
+++ b/drivers/scsi/qla2xxx/qla_target.h
@@ -374,8 +374,8 @@  struct atio_from_isp {
 static inline int fcpcmd_is_corrupted(struct atio *atio)
 {
 	if (atio->entry_type == ATIO_TYPE7 &&
-	    (le16_to_cpu(atio->attr_n_length & FCP_CMD_LENGTH_MASK) <
-	    FCP_CMD_LENGTH_MIN))
+	    ((le16_to_cpu(atio->attr_n_length) & FCP_CMD_LENGTH_MASK) <
+	     FCP_CMD_LENGTH_MIN))
 		return 1;
 	else
 		return 0;