Commit 26920622 authored by Alexander Duyck's avatar Alexander Duyck Committed by Kleber Sacilotto de Souza

libnvdimm: Hold reference on parent while scheduling async init

BugLink: https://bugs.launchpad.net/bugs/1810947

commit b6eae0f6 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: 4d88a97a ("libnvdimm: ...base ... infrastructure")
Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@linux.intel.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 907c383f
...@@ -158,6 +158,8 @@ static void nd_async_device_register(void *d, async_cookie_t cookie) ...@@ -158,6 +158,8 @@ static void nd_async_device_register(void *d, async_cookie_t cookie)
put_device(dev); put_device(dev);
} }
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) static void nd_async_device_unregister(void *d, async_cookie_t cookie)
...@@ -175,6 +177,8 @@ static void nd_async_device_unregister(void *d, async_cookie_t cookie) ...@@ -175,6 +177,8 @@ static void nd_async_device_unregister(void *d, async_cookie_t cookie)
void __nd_device_register(struct device *dev) void __nd_device_register(struct device *dev)
{ {
dev->bus = &nvdimm_bus_type; dev->bus = &nvdimm_bus_type;
if (dev->parent)
get_device(dev->parent);
get_device(dev); get_device(dev);
async_schedule_domain(nd_async_device_register, dev, async_schedule_domain(nd_async_device_register, dev,
&nd_async_domain); &nd_async_domain);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment