diff options
author | Alban Bedel <albeu@free.fr> | 2019-01-28 16:55:04 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-01-31 16:24:14 +0100 |
commit | 95b65195d571ab589a6d6893a418922757e06399 (patch) | |
tree | ee111e025dff984fb7d70f8debb4a506c8c30f8d | |
parent | nvmem: core: Properly handle connection ID in of_nvmem_device_get() (diff) | |
download | linux-95b65195d571ab589a6d6893a418922757e06399.tar.xz linux-95b65195d571ab589a6d6893a418922757e06399.zip |
nvmem: core: Always reference the device returned by nvmem_device_get()
In nvmem_device_get(), when the device lookup fails with DT it
currently fallback on nvmem_find() which is wrong for two reasons.
First nvmem_find() return NULL when nothing is found instead of an
ERR_PTR. But nvmem_find() also just lookup the device, it doesn't
reference the module and increment the reference count like it is done
in the DT path.
To fix this we replace the call to nvmem_find() with a call to
__nvmem_device_get() which does all the referencing and return a
proper ERR_PTR in case of error.
Signed-off-by: Alban Bedel <albeu@free.fr>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/nvmem/core.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index a749a5cb0a4e..1752768dd2d2 100644 --- a/drivers/nvmem/core.c +++ b/drivers/nvmem/core.c @@ -874,7 +874,7 @@ struct nvmem_device *nvmem_device_get(struct device *dev, const char *dev_name) } - return nvmem_find(dev_name); + return __nvmem_device_get(NULL, dev_name); } EXPORT_SYMBOL_GPL(nvmem_device_get); |