Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cba690fe authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Greg Kroah-Hartman
Browse files

irda: vlsi_ir: fix check for DMA mapping errors




[ Upstream commit 6ac3b77a6ffff7513ff86b684aa256ea01c0e5b5 ]

vlsi_alloc_ring() checks for DMA mapping errors by comparing
returned address with zero, while pci_dma_mapping_error() should be used.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7570a653
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -426,8 +426,9 @@ static struct vlsi_ring *vlsi_alloc_ring(struct pci_dev *pdev, struct ring_descr
		memset(rd, 0, sizeof(*rd));
		memset(rd, 0, sizeof(*rd));
		rd->hw = hwmap + i;
		rd->hw = hwmap + i;
		rd->buf = kmalloc(len, GFP_KERNEL|GFP_DMA);
		rd->buf = kmalloc(len, GFP_KERNEL|GFP_DMA);
		if (rd->buf == NULL ||
		if (rd->buf)
		    !(busaddr = pci_map_single(pdev, rd->buf, len, dir))) {
			busaddr = pci_map_single(pdev, rd->buf, len, dir);
		if (rd->buf == NULL || pci_dma_mapping_error(pdev, busaddr)) {
			if (rd->buf) {
			if (rd->buf) {
				IRDA_ERROR("%s: failed to create PCI-MAP for %p",
				IRDA_ERROR("%s: failed to create PCI-MAP for %p",
					   __func__, rd->buf);
					   __func__, rd->buf);
@@ -438,7 +439,6 @@ static struct vlsi_ring *vlsi_alloc_ring(struct pci_dev *pdev, struct ring_descr
				rd = r->rd + j;
				rd = r->rd + j;
				busaddr = rd_get_addr(rd);
				busaddr = rd_get_addr(rd);
				rd_set_addr_status(rd, 0, 0);
				rd_set_addr_status(rd, 0, 0);
				if (busaddr)
				pci_unmap_single(pdev, busaddr, len, dir);
				pci_unmap_single(pdev, busaddr, len, dir);
				kfree(rd->buf);
				kfree(rd->buf);
				rd->buf = NULL;
				rd->buf = NULL;