From ad4efe4fc5363e79bf6db87b012b73189806f4c7 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 3 Dec 2008 17:17:07 -0700 Subject: dmaengine: protect 'id' from concurrent registrations commit b0b42b16ff2b90f17bc1a4308366c9beba4b276e upstream. There is a possibility to have two devices registered with the same id. Acked-by: Maciej Sosnowski Signed-off-by: Dan Williams Signed-off-by: Greg Kroah-Hartman --- drivers/dma/dmaengine.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/dma') diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index dc003a3a787d..53bb74b2af67 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c @@ -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) { -- cgit v1.2.3