Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / net / caif / caif_dev.c
index 7c2fa0a..47fc8f3 100644 (file)
@@ -93,10 +93,14 @@ static struct caif_device_entry *caif_device_alloc(struct net_device *dev)
        caifdevs = caif_device_list(dev_net(dev));
        BUG_ON(!caifdevs);
 
-       caifd = kzalloc(sizeof(*caifd), GFP_ATOMIC);
+       caifd = kzalloc(sizeof(*caifd), GFP_KERNEL);
        if (!caifd)
                return NULL;
        caifd->pcpu_refcnt = alloc_percpu(int);
+       if (!caifd->pcpu_refcnt) {
+               kfree(caifd);
+               return NULL;
+       }
        caifd->netdev = dev;
        dev_hold(dev);
        return caifd;
@@ -208,8 +212,7 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
        enum cfcnfg_phy_preference pref;
        enum cfcnfg_phy_type phy_type;
        struct cfcnfg *cfg;
-       struct caif_device_entry_list *caifdevs =
-           caif_device_list(dev_net(dev));
+       struct caif_device_entry_list *caifdevs;
 
        if (dev->type != ARPHRD_CAIF)
                return 0;
@@ -218,6 +221,8 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
        if (cfg == NULL)
                return 0;
 
+       caifdevs = caif_device_list(dev_net(dev));
+
        switch (what) {
        case NETDEV_REGISTER:
                caifd = caif_device_alloc(dev);