Skip to content

Commit fa72d84

Browse files
brglgregkh
authored andcommitted
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 <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f9fcb7e commit fa72d84

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/nvmem/core.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,17 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
512512
goto err_device_del;
513513
}
514514

515-
if (config->cells)
516-
nvmem_add_cells(nvmem, config->cells, config->ncells);
515+
if (config->cells) {
516+
rval = nvmem_add_cells(nvmem, config->cells, config->ncells);
517+
if (rval)
518+
goto err_teardown_compat;
519+
}
517520

518521
return nvmem;
519522

523+
err_teardown_compat:
524+
if (config->compat)
525+
device_remove_bin_file(nvmem->base_dev, &nvmem->eeprom);
520526
err_device_del:
521527
device_del(&nvmem->dev);
522528
err_put_device:

0 commit comments

Comments
 (0)