]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: core: fix the dma_max_mapping_size call
authorChristoph Hellwig <hch@lst.de>
Mon, 22 Jul 2019 09:20:38 +0000 (11:20 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 23 Jul 2019 02:05:48 +0000 (22:05 -0400)
commit16008442dea1b2d49d438770ef12f96f6881c097
tree8433fa141ffb58e7d4343a1d18d4b3da9d1e3a05
parent7b409a4b971f98cbe759b9987a0538321f0e6c34
scsi: core: fix the dma_max_mapping_size call

We should only call dma_max_mapping_size for devices that have a DMA mask
set, otherwise we can run into a NULL pointer dereference that will crash
the system.

Also we need to do right shift to get the sectors from the size in bytes,
not a left shift.

Fixes: 88b82c34c10b ("scsi: core: take the DMA max mapping size into account")
Reported-by: Bart Van Assche <bvanassche@acm.org>
Reported-by: Ming Lei <tom.leiming@gmail.com>
Tested-by: Guilherme G. Piccoli <gpiccoli@canonical.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_lib.c