diff mbox

scsi: qla2xxx: Off by one in qlt_ctio_to_cmd()

Message ID 20170710084739.tjj7juaex7cb7xs5@mwanda (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Dan Carpenter July 10, 2017, 8:47 a.m. UTC
There are "req->num_outstanding_cmds" elements in the
req->outstanding_cmds[] array so the > here should be >=.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Nicholas A. Bellinger July 11, 2017, 9:14 a.m. UTC | #1
On Mon, 2017-07-10 at 11:47 +0300, Dan Carpenter wrote:
> There are "req->num_outstanding_cmds" elements in the
> req->outstanding_cmds[] array so the > here should be >=.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
> index 6e4794367e0b..ecd1a95511f9 100644
> --- a/drivers/scsi/qla2xxx/qla_target.c
> +++ b/drivers/scsi/qla2xxx/qla_target.c
> @@ -3728,7 +3728,7 @@ static struct qla_tgt_cmd *qlt_ctio_to_cmd(struct scsi_qla_host *vha,
>  	h &= QLA_CMD_HANDLE_MASK;
>  
>  	if (h != QLA_TGT_NULL_HANDLE) {
> -		if (unlikely(h > req->num_outstanding_cmds)) {
> +		if (unlikely(h >= req->num_outstanding_cmds)) {
>  			ql_dbg(ql_dbg_tgt, vha, 0xe052,
>  			    "qla_target(%d): Wrong handle %x received\n",
>  			    vha->vp_idx, handle);

Nice catch.

Reviewed-by: Nicholas Bellinger <nab@linux-iscsi.org>
Martin K. Petersen July 12, 2017, 9:20 p.m. UTC | #2
Dan,

> There are "req->num_outstanding_cmds" elements in the
> req->outstanding_cmds[] array so the > here should be >=.

Applied to 4.13/scsi-fixes. Thanks!
diff mbox

Patch

diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index 6e4794367e0b..ecd1a95511f9 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -3728,7 +3728,7 @@  static struct qla_tgt_cmd *qlt_ctio_to_cmd(struct scsi_qla_host *vha,
 	h &= QLA_CMD_HANDLE_MASK;
 
 	if (h != QLA_TGT_NULL_HANDLE) {
-		if (unlikely(h > req->num_outstanding_cmds)) {
+		if (unlikely(h >= req->num_outstanding_cmds)) {
 			ql_dbg(ql_dbg_tgt, vha, 0xe052,
 			    "qla_target(%d): Wrong handle %x received\n",
 			    vha->vp_idx, handle);