From 2f73b9a896634dd0ce68b5af9ae5f475e24ce51e Mon Sep 17 00:00:00 2001 From: Roland Dreier Date: Wed, 30 Nov 2011 16:30:33 -0800 Subject: [PATCH] [SCSI] mpt2sas: Fix possible integer truncation of cpu_count 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. Signed-off-by: Roland Dreier Acked-by: "Nandigama, Nagalakshmi" Signed-off-by: James Bottomley --- drivers/scsi/mpt2sas/mpt2sas_base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c index 65c377d..2da49cd 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.c +++ b/drivers/scsi/mpt2sas/mpt2sas_base.c @@ -1407,7 +1407,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), -- 2.7.4