diff mbox

[2/4] brcmsmac: Free packet if dma_mapping_error() fails in dma_rxfill

Message ID 1468884277-18606-3-git-send-email-f.fainelli@gmail.com (mailing list archive)
State Accepted
Commit 5c5fa1f464ac954982df1d96b9f9a5103d21aedd
Delegated to: Kalle Valo
Headers show

Commit Message

Florian Fainelli July 18, 2016, 11:24 p.m. UTC
In case dma_mapping_error() returns an error in dma_rxfill, we would be
leaking a packet that we allocated with brcmu_pkt_buf_get_skb().

Reported-by: coverity (CID 1081819)
Fixes: 67d0cf50bd32 ("brcmsmac: Fix WARNING caused by lack of calls to dma_mapping_error()")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Arend van Spriel July 19, 2016, 9:25 a.m. UTC | #1
On 19-7-2016 1:24, Florian Fainelli wrote:
> In case dma_mapping_error() returns an error in dma_rxfill, we would be
> leaking a packet that we allocated with brcmu_pkt_buf_get_skb().
> 
> Reported-by: coverity (CID 1081819)
> Fixes: 67d0cf50bd32 ("brcmsmac: Fix WARNING caused by lack of calls to dma_mapping_error()")

Acked-by: Arend van Spriel <arend@broadcom.com>
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c
> index 796f5f9d5d5a..b7df576bb84d 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c
> @@ -1079,8 +1079,10 @@ bool dma_rxfill(struct dma_pub *pub)
>  
>  		pa = dma_map_single(di->dmadev, p->data, di->rxbufsize,
>  				    DMA_FROM_DEVICE);
> -		if (dma_mapping_error(di->dmadev, pa))
> +		if (dma_mapping_error(di->dmadev, pa)) {
> +			brcmu_pkt_buf_free_skb(p);
>  			return false;
> +		}
>  
>  		/* save the free packet pointer */
>  		di->rxp[rxout] = p;
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c
index 796f5f9d5d5a..b7df576bb84d 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/dma.c
@@ -1079,8 +1079,10 @@  bool dma_rxfill(struct dma_pub *pub)
 
 		pa = dma_map_single(di->dmadev, p->data, di->rxbufsize,
 				    DMA_FROM_DEVICE);
-		if (dma_mapping_error(di->dmadev, pa))
+		if (dma_mapping_error(di->dmadev, pa)) {
+			brcmu_pkt_buf_free_skb(p);
 			return false;
+		}
 
 		/* save the free packet pointer */
 		di->rxp[rxout] = p;