mirror of
https://github.com/torvalds/linux.git
synced 2026-11-30 02:23:05 +00:00
nvmem: core: fix error handling while validating keepout regions
Current error path on failure of validating keepout regions is calling
put_device, eventhough the device is not even registered at that point.
Fix this by adding proper error handling of freeing ida and nvmem.
Fixes: fd3bb8f54a ("nvmem: core: Add support for keepout regions")
Cc: <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7b808449f5
commit
de0534df93
@@ -824,8 +824,11 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
|
||||
|
||||
if (nvmem->nkeepout) {
|
||||
rval = nvmem_validate_keepouts(nvmem);
|
||||
if (rval)
|
||||
goto err_put_device;
|
||||
if (rval) {
|
||||
ida_free(&nvmem_ida, nvmem->id);
|
||||
kfree(nvmem);
|
||||
return ERR_PTR(rval);
|
||||
}
|
||||
}
|
||||
|
||||
dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name);
|
||||
|
||||
Reference in New Issue
Block a user