Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1628939

Re: [PATCH] scsi: mvumi: add check for dma mapping errors

From Christoph Hellwig <hch@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH] scsi: mvumi: add check for dma mapping errors
Date 2017-04-23 10:50 +0200
Message-ID <tzlns-68k-3@gated-at.bofh.it> (permalink)
References <tyQ0i-3xb-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, Apr 22, 2017 at 02:17:50AM +0300, Alexey Khoroshilov wrote:
>  	} else {
> -		scmd->SCp.dma_handle = scsi_bufflen(scmd) ?
> -			pci_map_single(mhba->pdev, scsi_sglist(scmd),
> -				scsi_bufflen(scmd),
> -				(int) scmd->sc_data_direction)
> -			: 0;
> +		if (!scsi_bufflen(scmd))
> +			return -1;
> +		scmd->SCp.dma_handle = pci_map_single(mhba->pdev,
> +						scsi_sglist(scmd),
> +						scsi_bufflen(scmd),
> +						(int) scmd->sc_data_direction);
> +		if (pci_dma_mapping_error(mhba->pdev, scmd->SCp.dma_handle))
> +			return -1;

This looks completely broken.  Why would you DMA map the in-memory
struct scatterlist?  It has no meaning for the hardware.

In fact this whole branch (and the equivalent in the unmap path)
are dead - SCSI commands that transfer data always have a SG entry.

So the right fix is to remove the !scsi_sg_count(scmd) map/unmap
path.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] scsi: mvumi: add check for dma mapping errors Alexey Khoroshilov <khoroshilov@ispras.ru> - 2017-04-22 01:20 +0200
  Re: [PATCH] scsi: mvumi: add check for dma mapping errors Christoph Hellwig <hch@infradead.org> - 2017-04-23 10:50 +0200
    [PATCH] scsi: mvumi: remove code handling zero scsi_sg_count(scmd) case Alexey Khoroshilov <khoroshilov@ispras.ru> - 2017-04-24 01:10 +0200
      Re: [PATCH] scsi: mvumi: remove code handling zero  scsi_sg_count(scmd) case Christoph Hellwig <hch@infradead.org> - 2017-04-24 08:40 +0200

csiph-web