]> git.baikalelectronics.ru Git - kernel.git/commit
nvmem: core: Always reference the device returned by nvmem_device_get()
authorAlban Bedel <albeu@free.fr>
Mon, 28 Jan 2019 15:55:04 +0000 (15:55 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 31 Jan 2019 15:24:14 +0000 (16:24 +0100)
commit88850404593fa974768fc3e2017147cca15f557c
treeee111e025dff984fb7d70f8debb4a506c8c30f8d
parent88a97a9aa0f88e7dfc6630407f78f26d68c09e25
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>
drivers/nvmem/core.c