]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
nvmem: check the return value of nvmem_add_cells()
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Fri, 21 Sep 2018 13:40:07 +0000 (06:40 -0700)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:58:19 +0000 (19:58 -0600)
BugLink: https://bugs.launchpad.net/bugs/1836802
[ Upstream commit fa72d847d68d7833b77a4bef944cf2c5baf56f49 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/nvmem/core.c

index b3b2e03d3eb1804aae85834dfea1898665e0e508..87bea4431ee6119076f56781d130c19b6b142c6b 100644 (file)
@@ -505,11 +505,17 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
                        goto err_device_del;
        }
 
-       if (config->cells)
-               nvmem_add_cells(nvmem, config);
+       if (config->cells) {
+               rval = nvmem_add_cells(nvmem, config);
+               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: