IB/nes: Fix a race condition in nes_inetaddr_event()
authorBart Van Assche <bart.vanassche@wdc.com>
Wed, 11 Oct 2017 17:49:12 +0000 (10:49 -0700)
committerDoug Ledford <dledford@redhat.com>
Sun, 15 Oct 2017 00:47:07 +0000 (20:47 -0400)
This patch has been compile-tested only.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Cc: Faisal Latif <faisal.latif@intel.com>
Acked-by: Faisal Latif <fasial.latif@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/nes/nes.c

index ff58dfa071b83ab0effd940dec39d1946b7d58af..42b68aa999fcfa2e16396a267bd292d24927f80f 100644 (file)
@@ -178,11 +178,16 @@ static int nes_inetaddr_event(struct notifier_block *notifier,
                                        /* fall through */
                                case NETDEV_CHANGEADDR:
                                        /* Add the address to the IP table */
-                                       if (upper_dev)
-                                               nesvnic->local_ipaddr =
-                                                       ((struct in_device *)upper_dev->ip_ptr)->ifa_list->ifa_address;
-                                       else
+                                       if (upper_dev) {
+                                               struct in_device *in;
+
+                                               rcu_read_lock();
+                                               in = __in_dev_get_rcu(upper_dev);
+                                               nesvnic->local_ipaddr = in->ifa_list->ifa_address;
+                                               rcu_read_unlock();
+                                       } else {
                                                nesvnic->local_ipaddr = ifa->ifa_address;
+                                       }
 
                                        nes_write_indexed(nesdev,
                                                        NES_IDX_DST_IP_ADDR+(0x10*PCI_FUNC(nesdev->pcidev->devfn)),