]> xenbits.xensource.com Git - legacy/linux-2.6.18-xen.git/commitdiff
netfront accel: Over-eager locking meant kmalloc at GFP_KERNEL with irqs disabled
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 20 Dec 2007 16:58:14 +0000 (16:58 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 20 Dec 2007 16:58:14 +0000 (16:58 +0000)
Signed-off-by Kieran Mansley <kmansley@solarflare.com>

drivers/xen/netfront/accel.c

index 78491c6970d9ecee03d2b94b72b6f0db57dfae64..ebef91cd76c620c17edf07c9d8a4e4792456dfb0 100644 (file)
@@ -273,6 +273,7 @@ static int init_accelerator(const char *frontend,
 {
        struct netfront_accelerator *accelerator = 
                kmalloc(sizeof(struct netfront_accelerator), GFP_KERNEL);
+       unsigned long flags;
        int frontend_len;
 
        if (!accelerator) {
@@ -294,7 +295,9 @@ static int init_accelerator(const char *frontend,
 
        accelerator->hooks = hooks;
 
+       spin_lock_irqsave(&accelerators_lock, flags);
        list_add(&accelerator->link, &accelerators_list);
+       spin_unlock_irqrestore(&accelerators_lock, flags);
 
        *result = accelerator;
 
@@ -365,20 +368,15 @@ static int netfront_load_accelerator(struct netfront_info *np,
 {
        struct netfront_accelerator *accelerator;
        int rc = 0;
-       unsigned long flags;
 
        DPRINTK(" %s\n", frontend);
 
-       spin_lock_irqsave(&accelerators_lock, flags);
-
        /* 
         * Look at list of loaded accelerators to see if the requested
         * one is already there 
         */
        list_for_each_entry(accelerator, &accelerators_list, link) {
                if (match_accelerator(frontend, accelerator)) {
-                       spin_unlock_irqrestore(&accelerators_lock, flags);
-
                        accelerator_probe_new_vif(np, dev, accelerator);
                        return 0;
                }
@@ -386,12 +384,9 @@ static int netfront_load_accelerator(struct netfront_info *np,
 
        /* Couldn't find it, so create a new one and load the module */
        if ((rc = init_accelerator(frontend, &accelerator, NULL)) < 0) {
-               spin_unlock_irqrestore(&accelerators_lock, flags);
                return rc;
        }
 
-       spin_unlock_irqrestore(&accelerators_lock, flags);
-
        /* Include this frontend device on the accelerator's list */
        add_accelerator_vif(accelerator, np);
 
@@ -450,7 +445,6 @@ int netfront_accelerator_loaded(int version, const char *frontend,
                                struct netfront_accel_hooks *hooks)
 {
        struct netfront_accelerator *accelerator;
-       unsigned long flags;
 
        if (version != NETFRONT_ACCEL_VERSION) {
                if (version > NETFRONT_ACCEL_VERSION) {
@@ -469,18 +463,13 @@ int netfront_accelerator_loaded(int version, const char *frontend,
 
        mutex_lock(&accelerator_mutex);
 
-       spin_lock_irqsave(&accelerators_lock, flags);
-
        /* 
         * Look through list of accelerators to see if it has already
         * been requested
         */
        list_for_each_entry(accelerator, &accelerators_list, link) {
                if (match_accelerator(frontend, accelerator)) {
-                       spin_unlock_irqrestore(&accelerators_lock, flags);
-
                        accelerator_probe_vifs(accelerator, hooks);
-
                        goto out;
                }
        }
@@ -494,8 +483,6 @@ int netfront_accelerator_loaded(int version, const char *frontend,
 
        init_accelerator(frontend, &accelerator, hooks);
 
-       spin_unlock_irqrestore(&accelerators_lock, flags);
-
  out:
        mutex_unlock(&accelerator_mutex);
        return 0;