Skip to content

Commit 61e6ba0

Browse files
suganathprabu0512martinkpetersen
authored andcommitted
scsi: mpt3sas: Fix memset() in non-RDPQ mode
Fix memset() accessing out of range address when reply_queue count is less than RDPQ_MAX_INDEX_IN_ONE_CHUNK (i.e. 16) in non-RDPQ mode. In non-RDPQ mode, the driver allocates a single contiguous pool of size reply_queue's count * reqly_post_free_sz. But the driver is always memsetting this pool with size 16 * reqly_post_free_sz. If reply queue count is less than 16 (i.e. when MSI-X vectors enabled < 16), the driver is accessing out of range address and this results in 'BUG: unable to handle kernel paging request at fff0x...x' bug. Make driver use dma_pool_zalloc() API to allocate and zero the pool. Link: https://lore.kernel.org/r/[email protected] Fixes: 8012209 ("scsi: mpt3sas: Handle RDPQ DMA allocation in same 4G region") Signed-off-by: Suganath Prabu S <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 0267ffc commit 61e6ba0

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

drivers/scsi/mpt3sas/mpt3sas_base.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4984,7 +4984,7 @@ base_alloc_rdpq_dma_pool(struct MPT3SAS_ADAPTER *ioc, int sz)
49844984
for (i = 0; i < count; i++) {
49854985
if ((i % RDPQ_MAX_INDEX_IN_ONE_CHUNK == 0) && dma_alloc_count) {
49864986
ioc->reply_post[i].reply_post_free =
4987-
dma_pool_alloc(ioc->reply_post_free_dma_pool,
4987+
dma_pool_zalloc(ioc->reply_post_free_dma_pool,
49884988
GFP_KERNEL,
49894989
&ioc->reply_post[i].reply_post_free_dma);
49904990
if (!ioc->reply_post[i].reply_post_free)
@@ -5008,9 +5008,6 @@ base_alloc_rdpq_dma_pool(struct MPT3SAS_ADAPTER *ioc, int sz)
50085008
ioc->reply_post[i].reply_post_free_dma));
50095009
return -EAGAIN;
50105010
}
5011-
memset(ioc->reply_post[i].reply_post_free, 0,
5012-
RDPQ_MAX_INDEX_IN_ONE_CHUNK *
5013-
reply_post_free_sz);
50145011
dma_alloc_count--;
50155012

50165013
} else {

0 commit comments

Comments
 (0)