diff mbox

cxlflash: off by one bug in cxlflash_show_port_status()

Message ID 20150814203525.GA27158@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter Aug. 14, 2015, 8:35 p.m. UTC
The > should be >= or we read one element past the end of the array.

Fixes: c21e0bbfc485 ('cxlflash: Base support for IBM CXL Flash Adapter')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Fixes: c21e0bbfc485 ('cxlflash: Base support for IBM CXL Flash Adapter')
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Matthew R. Ochs Aug. 16, 2015, 2:52 a.m. UTC | #1
> On Aug 14, 2015, at 3:35 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> The > should be >= or we read one element past the end of the array.

Dan - Good catch!

Acked-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com>

> 
> Fixes: c21e0bbfc485 ('cxlflash: Base support for IBM CXL Flash Adapter')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Fixes: c21e0bbfc485 ('cxlflash: Base support for IBM CXL Flash Adapter')
> diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
> index 0720d2f..fd70101 100644
> --- a/drivers/scsi/cxlflash/main.c
> +++ b/drivers/scsi/cxlflash/main.c
> @@ -539,7 +539,7 @@ static ssize_t cxlflash_show_port_status(struct device *dev,
> 	u64 *fc_regs;
> 
> 	rc = kstrtouint((attr->attr.name + 4), 10, &port);
> -	if (rc || (port > NUM_FC_PORTS))
> +	if (rc || (port >= NUM_FC_PORTS))
> 		return 0;
> 
> 	fc_regs = &afu->afu_map->global.fc_regs[port][0];
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index 0720d2f..fd70101 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -539,7 +539,7 @@  static ssize_t cxlflash_show_port_status(struct device *dev,
 	u64 *fc_regs;
 
 	rc = kstrtouint((attr->attr.name + 4), 10, &port);
-	if (rc || (port > NUM_FC_PORTS))
+	if (rc || (port >= NUM_FC_PORTS))
 		return 0;
 
 	fc_regs = &afu->afu_map->global.fc_regs[port][0];