[PATCH] scsi: bnx2fc: avoid a potential out of bound access

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

 



The size of free_list_lock and free_list is num_possible_cpus,
and cpu id returned by get_cpu() maybe bigger than
num_possible_cpus, due to the non-continuous cpu ids.

Signed-off-by: Li RongQing <lirongqing@xxxxxxxxx>
Signed-off-by: Wang Li <wangli39@xxxxxxxxx>
---
 drivers/scsi/bnx2fc/bnx2fc_io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 5a645b8b9af1..fab1a9f85360 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -472,7 +472,7 @@ struct bnx2fc_cmd *bnx2fc_cmd_alloc(struct bnx2fc_rport *tgt)
 	u32 free_sqes;
 	u32 max_sqes;
 	u16 xid;
-	int index = get_cpu();
+	int index = get_cpu() % num_possible_cpus();
 
 	max_sqes = BNX2FC_SCSI_MAX_SQES;
 	/*
-- 
2.16.2




[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