Commit cccb3b19 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Greg Kroah-Hartman

nvmem: fix nvmem_cell_get_from_lookup()

We check if the pointer returned by __nvmem_device_get() is not NULL
while we should actually check if it is not IS_ERR(nvmem). Fix it.

While we're at it: fix the next error path where we should assign an
error value to cell before returning.
Signed-off-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Acked-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent badcdff1
...@@ -953,9 +953,9 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id) ...@@ -953,9 +953,9 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id)
(strcmp(lookup->con_id, con_id) == 0)) { (strcmp(lookup->con_id, con_id) == 0)) {
/* This is the right entry. */ /* This is the right entry. */
nvmem = __nvmem_device_get(NULL, lookup->nvmem_name); nvmem = __nvmem_device_get(NULL, lookup->nvmem_name);
if (!nvmem) { if (IS_ERR(nvmem)) {
/* Provider may not be registered yet. */ /* Provider may not be registered yet. */
cell = ERR_PTR(-EPROBE_DEFER); cell = ERR_CAST(nvmem);
goto out; goto out;
} }
...@@ -963,6 +963,7 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id) ...@@ -963,6 +963,7 @@ nvmem_cell_get_from_lookup(struct device *dev, const char *con_id)
lookup->cell_name); lookup->cell_name);
if (!cell) { if (!cell) {
__nvmem_device_put(nvmem); __nvmem_device_put(nvmem);
cell = ERR_PTR(-ENOENT);
goto out; goto out;
} }
} }
......
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