scsi: mpt3sas: Fix reply queue count in non RDPQ mode
authorSuganath Prabu S <suganath-prabu.subramani@broadcom.com>
Fri, 22 May 2020 10:35:58 +0000 (06:35 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 26 May 2020 23:57:59 +0000 (19:57 -0400)
commitf56577e8c7d0f3054f97d1f0d1cbe9a4d179cc47
tree16fe084a8cc95e1a0bf25da2b74972a44ad6874c
parent7217e6e694da3aae6d17db8a7f7460c8d4817ebf
scsi: mpt3sas: Fix reply queue count in non RDPQ mode

For non RDPQ mode, the driver allocates a single contiguous block of memory
pool for all reply descriptor post queues and passes down a single address
in the ReplyDescriptorPostQueueAddress field of the IOC Init Request
Message to the firmware. So reply_post queue will have only one entry which
holds the address of this single contiguous block of memory pool.

While allocating the reply descriptor post queue pool, driver should loop
only once in non-RDPQ mode. But the driver is looping for
ioc->reply_queue_count number of times even though reply_post queue's queue
depth is only one in non-RDPQ mode. This leads to 'BUG: KASAN:
use-after-free in base_alloc_rdpq_dma_pool'.

The fix is to loop only once while allocating memory for the reply
descriptor post queue in non-RDPQ mode

Fixes: 8012209eb26b ("scsi: mpt3sas: Handle RDPQ DMA allocation in same 4G region")
Link: https://lore.kernel.org/r/20200522103558.5710-1-suganath-prabu.subramani@broadcom.com
Reported-by: Tomas Henzl <thenzl@redhat.com>
Reviewed-by: Tomas Henzl <thenzl@redhat.com>
Signed-off-by: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/mpt3sas/mpt3sas_base.c