Skip to contentSkip to conversation

net: ipa: pass correct dma_handle to dma_free_coherent()

PATCH Applied Dan Carpenter 3 participants 3 messages Feb 2, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ipa: pass correct dma_handle to dma_free_coherent()

The "ring->addr = addr;" assignment is done a few lines later so we can't use "ring->addr" yet. The correct dma_handle is "addr".

Fixes 650d1603825d ("soc: qcom: ipa: the generic software interface")

---
Smatch also complians about:

drivers/net/ipa/gsi.c:1739 gsi_channel_setup()
warn: missing error code 'ret'

It probably should return -EINVAL, but I'm not positive.

 drivers/net/ipa/gsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ipa/gsi.c +1 -1
index f79cf3c327c1..b559d14271e2 100644
@@ -1373,7 +1373,7 @@ static int gsi_ring_alloc(struct gsi *gsi, struct gsi_ring *ring, u32 count)
 	/* Hardware requires a 2^n ring size, with alignment equal to size */
 	ring->virt = dma_alloc_coherent(dev, size, &addr, GFP_KERNEL);
 	if (ring->virt && addr % size) {
-		dma_free_coherent(dev, size, ring->virt, ring->addr);
+		dma_free_coherent(dev, size, ring->virt, addr);
 		dev_err(dev, "unable to alloc 0x%zx-aligned ring buffer\n",
 			size);
 		return -EINVAL;	/* Not a good error value, but distinct */
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dan Carpenter

The "ring->addr = addr;" assignment is done a few lines later so we can't use "ring->addr" yet. The correct dma_handle is "addr".

Fixes 650d1603825d ("soc: qcom: ipa: the generic software interface")

Yikes. Thank you for the fix.

Quoted 25 lines

---
Smatch also complians about:

drivers/net/ipa/gsi.c:1739 gsi_channel_setup()
warn: missing error code 'ret'

It probably should return -EINVAL, but I'm not positive.

 drivers/net/ipa/gsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ipa/gsi.c +1 -1
index f79cf3c327c1..b559d14271e2 100644
@@ -1373,7 +1373,7 @@ static int gsi_ring_alloc(struct gsi *gsi, struct gsi_ring *ring, u32 count)
 	/* Hardware requires a 2^n ring size, with alignment equal to size */
 	ring->virt = dma_alloc_coherent(dev, size, &addr, GFP_KERNEL);
 	if (ring->virt && addr % size) {
-		dma_free_coherent(dev, size, ring->virt, ring->addr);
+		dma_free_coherent(dev, size, ring->virt, addr);
 		dev_err(dev, "unable to alloc 0x%zx-aligned ring buffer\n",
 			size);
 		return -EINVAL;	/* Not a good error value, but distinct */
maintainer Applied
#2 lore raw
Quoted 10 lines · On Tue, 2 Feb 2021 05:48:11 -0600 Alex Elder wrote:
Quoted 5 lines · Dan Carpenter

The "ring->addr = addr;" assignment is done a few lines later so we can't use "ring->addr" yet. The correct dma_handle is "addr".

Fixes 650d1603825d ("soc: qcom: ipa: the generic software interface")

Yikes. Thank you for the fix.

Applied, thanks!