cxlflash: off by one bug in cxlflash_show_port_status()
Subsystems (2)
PATCH 1/1 cxlflash: off by one bug in cxlflash_show_port_status()
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 <[email protected]>
Fixes c21e0bbfc485 ('cxlflash: Base support for IBM CXL Flash Adapter')
drivers/scsi/cxlflash/main.c +1 -1
@@ -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 ];
Quoted 3 lines · Dan Carpenter
The > should be >= or we read one element past the end of the array.
Dan - Good catch!
Acked-by Matthew R. Ochs <[email protected]>
Quoted 19 lines
Fixes c21e0bbfc485 ('cxlflash: Base support for IBM CXL Flash Adapter')Signed-off-by Dan Carpenter <[email protected]>Fixes c21e0bbfc485 ('cxlflash: Base support for IBM CXL Flash Adapter')drivers/scsi/cxlflash/main.c +1
-1@@ -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 ];