]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
fsl/fman: check dereferencing null pointer
authorFlorinel Iordache <florinel.iordache@nxp.com>
Mon, 3 Aug 2020 07:07:33 +0000 (10:07 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 3 Aug 2020 23:20:15 +0000 (16:20 -0700)
Add a safe check to avoid dereferencing null pointer

Fixes: 57ba4c9b56d8 ("fsl/fman: Add FMan MAC support")
Signed-off-by: Florinel Iordache <florinel.iordache@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/freescale/fman/fman_dtsec.c
drivers/net/ethernet/freescale/fman/fman_memac.c
drivers/net/ethernet/freescale/fman/fman_tgec.c

index 004c266802a87acff8d439dbd0d1d47d278a4786..bce3c9398887c834d5932973e12656ca91b8f9b2 100644 (file)
@@ -1200,7 +1200,7 @@ int dtsec_del_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr)
                list_for_each(pos,
                              &dtsec->multicast_addr_hash->lsts[bucket]) {
                        hash_entry = ETH_HASH_ENTRY_OBJ(pos);
-                       if (hash_entry->addr == addr) {
+                       if (hash_entry && hash_entry->addr == addr) {
                                list_del_init(&hash_entry->node);
                                kfree(hash_entry);
                                break;
@@ -1213,7 +1213,7 @@ int dtsec_del_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr)
                list_for_each(pos,
                              &dtsec->unicast_addr_hash->lsts[bucket]) {
                        hash_entry = ETH_HASH_ENTRY_OBJ(pos);
-                       if (hash_entry->addr == addr) {
+                       if (hash_entry && hash_entry->addr == addr) {
                                list_del_init(&hash_entry->node);
                                kfree(hash_entry);
                                break;
index bb02b37422cc20f5fa90728e487aa0fe60d50822..645764abdaae595b32c9aeee76c85657e0e23d69 100644 (file)
@@ -981,7 +981,7 @@ int memac_del_hash_mac_address(struct fman_mac *memac, enet_addr_t *eth_addr)
 
        list_for_each(pos, &memac->multicast_addr_hash->lsts[hash]) {
                hash_entry = ETH_HASH_ENTRY_OBJ(pos);
-               if (hash_entry->addr == addr) {
+               if (hash_entry && hash_entry->addr == addr) {
                        list_del_init(&hash_entry->node);
                        kfree(hash_entry);
                        break;
index 8c7eb878d5b4379026e58a4f861cd5239c744e13..41946b16f6c724626342d8435ac33917c065700a 100644 (file)
@@ -626,7 +626,7 @@ int tgec_del_hash_mac_address(struct fman_mac *tgec, enet_addr_t *eth_addr)
 
        list_for_each(pos, &tgec->multicast_addr_hash->lsts[hash]) {
                hash_entry = ETH_HASH_ENTRY_OBJ(pos);
-               if (hash_entry->addr == addr) {
+               if (hash_entry && hash_entry->addr == addr) {
                        list_del_init(&hash_entry->node);
                        kfree(hash_entry);
                        break;