Use rcu_dereference() before we dereference an RCU-protected pointer.
authorBen Pfaff <blp@nicira.com>
Tue, 30 Dec 2008 19:23:36 +0000 (11:23 -0800)
committerBen Pfaff <blp@nicira.com>
Tue, 30 Dec 2008 19:32:56 +0000 (11:32 -0800)
The access to dps[i]->netdev->name is a dereference that should be
protected by rcu_dereference().

datapath/datapath.c

index 2677445fe924a990553f09f8ffb453ed481897f0..5e1e70adb3702c8f1bc40d05b829742cbc948c3a 100644 (file)
@@ -1140,8 +1140,9 @@ struct datapath *dp_get_by_name(const char *dp_name)
                return NULL;
 
        for (i=0; i<DP_MAX; i++) {
-               if (dps[i] && !strncmp(dps[i]->netdev->name, dp_name, IFNAMSIZ))
-                       return rcu_dereference(dps[i]);
+               struct datapath *dp = rcu_dereference(dps[i]);
+               if (dp && !strncmp(dp->netdev->name, dp_name, IFNAMSIZ))
+                       return dp;
        }
        return NULL;
 }