brcmfmac: fix memory leak in brcmf_flowring_add_tdls_peer()
authorArend Van Spriel <arend.vanspriel@broadcom.com>
Mon, 19 Sep 2016 11:09:53 +0000 (12:09 +0100)
committerKalle Valo <kvalo@codeaurora.org>
Mon, 26 Sep 2016 17:35:53 +0000 (20:35 +0300)
In the error paths in brcmf_flowring_add_tdls_peer() the allocated
resource should be freed.

Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/broadcom/brcm80211/brcmfmac/flowring.c

index 7e269f9..b16b367 100644 (file)
@@ -495,14 +495,18 @@ void brcmf_flowring_add_tdls_peer(struct brcmf_flowring *flow, int ifidx,
        } else {
                search = flow->tdls_entry;
                if (memcmp(search->mac, peer, ETH_ALEN) == 0)
-                       return;
+                       goto free_entry;
                while (search->next) {
                        search = search->next;
                        if (memcmp(search->mac, peer, ETH_ALEN) == 0)
-                               return;
+                               goto free_entry;
                }
                search->next = tdls_entry;
        }
 
        flow->tdls_active = true;
+       return;
+
+free_entry:
+       kfree(tdls_entry);
 }