Skip to content

Commit

Permalink
[SCSI] mpt2sas: Fix possible integer truncation of cpu_count
Browse files Browse the repository at this point in the history
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 <roland@purestorage.com>
Acked-by: "Nandigama, Nagalakshmi" <Nagalakshmi.Nandigama@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
  • Loading branch information
Roland Dreier authored and James Bottomley committed Dec 15, 2011
1 parent c24a171 commit 2f73b9a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/scsi/mpt2sas/mpt2sas_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 2f73b9a

Please sign in to comment.