Skip to content

Commit

Permalink
nvmem: core: fix error handling while validating keepout regions
Browse files Browse the repository at this point in the history
commit de0534d upstream.

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: fd3bb8f ("nvmem: core: Add support for keepout regions")
Cc: <stable@vger.kernel.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20210806085947.22682-5-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Srinivas-Kandagatla authored and gregkh committed Sep 18, 2021
1 parent d1562b7 commit 63c2b13
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/nvmem/core.c
Expand Up @@ -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);
Expand Down

0 comments on commit 63c2b13

Please sign in to comment.