dmaengine: protect 'id' from concurrent registrations
authorDan Williams <dan.j.williams@intel.com>
Thu, 4 Dec 2008 00:17:07 +0000 (17:17 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 14 Jan 2009 17:44:03 +0000 (09:44 -0800)
commit b0b42b16ff2b90f17bc1a4308366c9beba4b276e upstream.

There is a possibility to have two devices registered with the same id.

Acked-by: Maciej Sosnowski <maciej.sosnowski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/dma/dmaengine.c

index dc003a3..53bb74b 100644 (file)
@@ -388,7 +388,10 @@ int dma_async_device_register(struct dma_device *device)
 
        init_completion(&device->done);
        kref_init(&device->refcount);
+
+       mutex_lock(&dma_list_mutex);
        device->dev_id = id++;
+       mutex_unlock(&dma_list_mutex);
 
        /* represent channels in sysfs. Probably want devs too */
        list_for_each_entry(chan, &device->channels, device_node) {