summaryrefslogtreecommitdiff
path: root/drivers/nvmem/core.c
diff options
context:
space:
mode:
authorBartosz Golaszewski <bgolaszewski@baylibre.com>2018-09-21 16:40:07 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-09-28 16:14:54 +0300
commitfa72d847d68d7833b77a4bef944cf2c5baf56f49 (patch)
tree203df28300e9de263987dba22d7d4a7f7a01dd7e /drivers/nvmem/core.c
parentf9fcb7e36cdec27e996606b8b33337056559f8da (diff)
downloadlinux-fa72d847d68d7833b77a4bef944cf2c5baf56f49.tar.xz
nvmem: check the return value of nvmem_add_cells()
This function can fail so check its return value in nvmem_register() and act accordingly. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/nvmem/core.c')
-rw-r--r--drivers/nvmem/core.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 1ced9caa811b..0ef84441ebe5 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -512,11 +512,17 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
goto err_device_del;
}
- if (config->cells)
- nvmem_add_cells(nvmem, config->cells, config->ncells);
+ if (config->cells) {
+ rval = nvmem_add_cells(nvmem, config->cells, config->ncells);
+ if (rval)
+ goto err_teardown_compat;
+ }
return nvmem;
+err_teardown_compat:
+ if (config->compat)
+ device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom);
err_device_del:
device_del(&nvmem->dev);
err_put_device: