diff mbox series

[net] net: ipa: pass correct dma_handle to dma_free_coherent()

Message ID YBjpTU2oejkNIULT@mwanda (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series [net] net: ipa: pass correct dma_handle to dma_free_coherent() | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Dan Carpenter Feb. 2, 2021, 5:55 a.m. UTC
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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
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(-)

Comments

Alex Elder Feb. 2, 2021, 11:48 a.m. UTC | #1
On 2/1/21 11:55 PM, Dan Carpenter wrote:
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Yikes.  Thank you for the fix.

Reviewed-by: Alex Elder <elder@linaro.org>

> ---
> 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(-)
> 
> diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c
> index f79cf3c327c1..b559d14271e2 100644
> --- a/drivers/net/ipa/gsi.c
> +++ b/drivers/net/ipa/gsi.c
> @@ -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 */
>
Jakub Kicinski Feb. 2, 2021, 4:47 p.m. UTC | #2
On Tue, 2 Feb 2021 05:48:11 -0600 Alex Elder wrote:
> On 2/1/21 11:55 PM, Dan Carpenter wrote:
> > 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")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>  
> 
> Yikes.  Thank you for the fix.
> 
> Reviewed-by: Alex Elder <elder@linaro.org>

Applied, thanks!
diff mbox series

Patch

diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c
index f79cf3c327c1..b559d14271e2 100644
--- a/drivers/net/ipa/gsi.c
+++ b/drivers/net/ipa/gsi.c
@@ -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 */