* [PATCH] irda: vlsi_ir: fix check for dma mapping errors
@ 2017-03-24 22:48 Alexey Khoroshilov
2017-03-25 10:19 ` Sergei Shtylyov
2017-03-26 3:14 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Alexey Khoroshilov @ 2017-03-24 22:48 UTC (permalink / raw)
To: Samuel Ortiz; +Cc: Alexey Khoroshilov, netdev, linux-kernel, ldv-project
vlsi_alloc_ring() checks for dma mapping errors by comparison
returned address with zero, while pci_dma_mapping_error() should be used.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
drivers/net/irda/vlsi_ir.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index ffedad2a360a..15b920086251 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -418,8 +418,9 @@ static struct vlsi_ring *vlsi_alloc_ring(struct pci_dev *pdev, struct ring_descr
memset(rd, 0, sizeof(*rd));
rd->hw = hwmap + i;
rd->buf = kmalloc(len, GFP_KERNEL|GFP_DMA);
- if (rd->buf == NULL ||
- !(busaddr = pci_map_single(pdev, rd->buf, len, dir))) {
+ if (rd->buf)
+ busaddr = pci_map_single(pdev, rd->buf, len, dir);
+ if (rd->buf == NULL || pci_dma_mapping_error(pdev, busaddr)) {
if (rd->buf) {
net_err_ratelimited("%s: failed to create PCI-MAP for %p\n",
__func__, rd->buf);
@@ -430,8 +431,7 @@ static struct vlsi_ring *vlsi_alloc_ring(struct pci_dev *pdev, struct ring_descr
rd = r->rd + j;
busaddr = rd_get_addr(rd);
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);
rd->buf = NULL;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] irda: vlsi_ir: fix check for dma mapping errors
2017-03-24 22:48 [PATCH] irda: vlsi_ir: fix check for dma mapping errors Alexey Khoroshilov
@ 2017-03-25 10:19 ` Sergei Shtylyov
2017-03-26 3:14 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Sergei Shtylyov @ 2017-03-25 10:19 UTC (permalink / raw)
To: Alexey Khoroshilov, Samuel Ortiz; +Cc: netdev, linux-kernel, ldv-project
Hello!
On 3/25/2017 1:48 AM, Alexey Khoroshilov wrote:
> vlsi_alloc_ring() checks for dma mapping errors by comparison
DMA. Comparing.
> returned address with zero, while pci_dma_mapping_error() should be used.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
> drivers/net/irda/vlsi_ir.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
> index ffedad2a360a..15b920086251 100644
> --- a/drivers/net/irda/vlsi_ir.c
> +++ b/drivers/net/irda/vlsi_ir.c
> @@ -418,8 +418,9 @@ static struct vlsi_ring *vlsi_alloc_ring(struct pci_dev *pdev, struct ring_descr
> memset(rd, 0, sizeof(*rd));
> rd->hw = hwmap + i;
> rd->buf = kmalloc(len, GFP_KERNEL|GFP_DMA);
> - if (rd->buf == NULL ||
> - !(busaddr = pci_map_single(pdev, rd->buf, len, dir))) {
> + if (rd->buf)
> + busaddr = pci_map_single(pdev, rd->buf, len, dir);
> + if (rd->buf == NULL || pci_dma_mapping_error(pdev, busaddr)) {
'!rd->buf' is preferred in the networking trees.
[...]
MBR, Sergei
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] irda: vlsi_ir: fix check for dma mapping errors
2017-03-24 22:48 [PATCH] irda: vlsi_ir: fix check for dma mapping errors Alexey Khoroshilov
2017-03-25 10:19 ` Sergei Shtylyov
@ 2017-03-26 3:14 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-03-26 3:14 UTC (permalink / raw)
To: khoroshilov; +Cc: samuel, netdev, linux-kernel, ldv-project
From: Alexey Khoroshilov <khoroshilov@ispras.ru>
Date: Sat, 25 Mar 2017 01:48:08 +0300
> vlsi_alloc_ring() checks for dma mapping errors by comparison
> returned address with zero, while pci_dma_mapping_error() should be used.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-26 3:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-24 22:48 [PATCH] irda: vlsi_ir: fix check for dma mapping errors Alexey Khoroshilov
2017-03-25 10:19 ` Sergei Shtylyov
2017-03-26 3:14 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).