From: Hante Meuleman <hante.meule...@broadcom.com>

When IPv6 address is to be cleared there is a possible out of
bound access. But also the clearing of the last entry and the
adjustment of total number of stored IPv6 addresses is not
updated. This patch fixes that bug. Bug was found using coverity.

Reviewed-by: Arend Van Spriel <arend.vanspr...@broadcom.com>
Reviewed-by: Franky Lin <franky....@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesbe...@broadcom.com>
Signed-off-by: Hante Meuleman <hante.meule...@broadcom.com>
Signed-off-by: Arend van Spriel <arend.vanspr...@broadcom.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c 
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 3394184..bb71199 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -873,9 +873,12 @@ static int brcmf_inet6addr_changed(struct notifier_block 
*nb,
                }
                break;
        case NETDEV_DOWN:
-               if (i < NDOL_MAX_ENTRIES)
-                       for (; i < ifp->ipv6addr_idx; i++)
+               if (i < NDOL_MAX_ENTRIES) {
+                       for (; i < ifp->ipv6addr_idx - 1; i++)
                                table[i] = table[i + 1];
+                       memset(&table[i], 0, sizeof(table[i]));
+                       ifp->ipv6addr_idx--;
+               }
                break;
        default:
                break;
-- 
1.9.1

Reply via email to