Ensure that the allocated nvmem structure is freed if device
registration return error code.
The missing kfree() caused a memory leak when nvmem_register()
exited via err_put_device label.
Signed-off-by: Alok Tiwari <alok.a.tiwari@xxxxxxxxxx>
---
drivers/nvmem/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index fd2a9698d1c9..3203524ad49f 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -1044,6 +1044,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
nvmem_sysfs_remove_compat(nvmem, config);
err_put_device:
put_device(&nvmem->dev);
+ kfree(nvmem);
return ERR_PTR(rval);
}