]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
libnvdimm: pfn_devs: Fix locking in namespace_store
authorAxel Lin <axel.lin@ingics.com>
Wed, 16 Sep 2015 13:25:38 +0000 (21:25 +0800)
committerDan Duval <dan.duval@oracle.com>
Wed, 7 Dec 2016 17:19:54 +0000 (12:19 -0500)
Orabug: 22913653

Always take device_lock() before nvdimm_bus_lock() to prevent deadlock.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit 4ca8b57a0af145f4e791f21dbca6ad789da9ee8b)
Signed-off-by: Dan Duval <dan.duval@oracle.com>
drivers/nvdimm/pfn_devs.c

index 3fd7d0d81a470b4cff54b093b0c24c6d14c376b5..71805a1aa0f3e5f002ee5d26339c53d49aadf951 100644 (file)
@@ -148,13 +148,13 @@ static ssize_t namespace_store(struct device *dev,
        struct nd_pfn *nd_pfn = to_nd_pfn(dev);
        ssize_t rc;
 
-       nvdimm_bus_lock(dev);
        device_lock(dev);
+       nvdimm_bus_lock(dev);
        rc = nd_namespace_store(dev, &nd_pfn->ndns, buf, len);
        dev_dbg(dev, "%s: result: %zd wrote: %s%s", __func__,
                        rc, buf, buf[len - 1] == '\n' ? "" : "\n");
-       device_unlock(dev);
        nvdimm_bus_unlock(dev);
+       device_unlock(dev);
 
        return rc;
 }