dma: of-dma: protect list write operation by spin_lock
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Thu, 14 Feb 2013 09:00:15 +0000 (11:00 +0200)
committerVinod Koul <vinod.koul@intel.com>
Thu, 14 Feb 2013 14:30:53 +0000 (20:00 +0530)
It's possible to have an inconsistency in the list due to unprotected operation
on it. The patch adds a proper locking on the list operation.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
drivers/dma/of-dma.c

index 583e50e3d47cb6ac1c4fafd9f3fe50882bc8fe74..69d04d28b1efbe78cb871b22af17bb851071e606 100644 (file)
@@ -118,7 +118,9 @@ int of_dma_controller_register(struct device_node *np,
        ofdma->use_count = 0;
 
        /* Now queue of_dma controller structure in list */
+       spin_lock(&of_dma_lock);
        list_add_tail(&ofdma->of_dma_controllers, &of_dma_list);
+       spin_unlock(&of_dma_lock);
 
        return 0;
 }