ieee1394: lock smaller region by host_num_alloc mutex
[platform/kernel/linux-arm64.git] / drivers / ieee1394 / hosts.c
index 8f4378a..25573ba 100644 (file)
@@ -123,7 +123,7 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
        int i;
        int hostnum = 0;
 
-       h = kzalloc(sizeof(*h) + extra, SLAB_KERNEL);
+       h = kzalloc(sizeof(*h) + extra, GFP_KERNEL);
        if (!h)
                return NULL;
 
@@ -157,10 +157,9 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
        h->speed_map = (u8 *)(h->csr.speed_map + 2);
 
        mutex_lock(&host_num_alloc);
-
        while (nodemgr_for_each_host(&hostnum, alloc_hostnum_cb))
                hostnum++;
-
+       mutex_unlock(&host_num_alloc);
        h->id = hostnum;
 
        memcpy(&h->device, &nodemgr_dev_template_host, sizeof(h->device));
@@ -175,8 +174,6 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
        class_device_register(&h->class_dev);
        get_device(&h->device);
 
-       mutex_unlock(&host_num_alloc);
-
        return h;
 }