]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
libnvdimm: Hold reference on parent while scheduling async init
authorAlexander Duyck <alexander.h.duyck@linux.intel.com>
Tue, 25 Sep 2018 20:53:02 +0000 (13:53 -0700)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:57:12 +0000 (19:57 -0600)
BugLink: https://bugs.launchpad.net/bugs/1836802
commit b6eae0f61db27748606cc00dafcfd1e2c032f0a5 upstream.

Unlike asynchronous initialization in the core we have not yet associated
the device with the parent, and as such the device doesn't hold a reference
to the parent.

In order to resolve that we should be holding a reference on the parent
until the asynchronous initialization has completed.

Cc: <stable@vger.kernel.org>
Fixes: 4d88a97aa9e8 ("libnvdimm: ...base ... infrastructure")
Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/nvdimm/bus.c

index a87e2c40db9dcebd4318d7d79417d2760206348b..df4a90c9e9a7146edb44bb37001ca8333eb59ae0 100644 (file)
@@ -484,6 +484,8 @@ static void nd_async_device_register(void *d, async_cookie_t cookie)
                put_device(dev);
        }
        put_device(dev);
+       if (dev->parent)
+               put_device(dev->parent);
 }
 
 static void nd_async_device_unregister(void *d, async_cookie_t cookie)
@@ -503,6 +505,8 @@ void __nd_device_register(struct device *dev)
        if (!dev)
                return;
        dev->bus = &nvdimm_bus_type;
+       if (dev->parent)
+               get_device(dev->parent);
        get_device(dev);
        async_schedule_domain(nd_async_device_register, dev,
                        &nd_async_domain);