mpt2sas: Fix possible integer truncation of cpu_count
PATCH 1/1 mpt2sas: Fix possible integer truncation of cpu_count
From: Roland Dreier <[email protected]>
When computing reply_queue_count (the number of MSI-X vectors to use), the driver does
ioc->reply_queue_count = min_t(u8, ioc->cpu_count, ioc->msix_vector_count);
However, on a big machine, ioc->cpu_count could be outside the range that fits in a u8; eg a system with 256 CPUs will end up reply_queue_count set to 0.
Fix this by calculating the minimum as ints and then letting the assignment to reply_queue_count handle integer demotion.
--- drivers/scsi/mpt2sas/mpt2sas_base.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/mpt2sas/mpt2sas_base.c +1 -1
@@ -1346,7 +1346,7 @@ _base_enable_msix(struct MPT2SAS_ADAPTER *ioc)if (_base_check_enable_msix (ioc) !=0 ) goto try_ioapic; - ioc->reply_queue_count =min_t (u8, ioc->cpu_count, + ioc->reply_queue_count =min_t (int, ioc->cpu_count, ioc->msix_vector_count); entries = kcalloc(ioc->reply_queue_count, sizeof(struct msix_entry),
Signature · 1 line
1.7.5.4
The patch seem to be fine.
Please consider this patch as acked by me.
Regards,
Nagalakshmi
-----Original Message-----
From: Roland Dreier [mailto:[email protected]] On Behalf Of Roland Dreier
Sent: Thursday, December 01, 2011 6:01 AM
To: James E.J. Bottomley
Cc: Nandigama, Nagalakshmi; [email protected]
Subject: [PATCH] [SCSI] mpt2sas: Fix possible integer truncation of cpu_count
From: Roland Dreier <[email protected]>
When computing reply_queue_count (the number of MSI-X vectors to use), the driver does
ioc->reply_queue_count = min_t(u8, ioc->cpu_count, ioc->msix_vector_count);
However, on a big machine, ioc->cpu_count could be outside the range that fits in a u8; eg a system with 256 CPUs will end up reply_queue_count set to 0.
Fix this by calculating the minimum as ints and then letting the assignment to reply_queue_count handle integer demotion.
--- drivers/scsi/mpt2sas/mpt2sas_base.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/mpt2sas/mpt2sas_base.c +1 -1
@@ -1346,7 +1346,7 @@ _base_enable_msix(struct MPT2SAS_ADAPTER *ioc)if (_base_check_enable_msix (ioc) !=0 ) goto try_ioapic; - ioc->reply_queue_count =min_t (u8, ioc->cpu_count, + ioc->reply_queue_count =min_t (int, ioc->cpu_count, ioc->msix_vector_count); entries = kcalloc(ioc->reply_queue_count, sizeof(struct msix_entry),
Signature · 1 line
1.7.5.4