diff options
author | Dinh Nguyen <dinguyen@kernel.org> | 2020-11-09 13:21:41 -0600 |
---|---|---|
committer | Philipp Zabel <p.zabel@pengutronix.de> | 2020-12-01 11:37:12 +0100 |
commit | 0d625a167b169f0bfdfd2e4dc05b9c89b81efe98 (patch) | |
tree | 84c3657eaa4be5d11c96c9e446a10387cd110ddf /drivers/reset | |
parent | 3bfe8933f9d187f93f0d0910b741a59070f58c4c (diff) | |
download | linux-0d625a167b169f0bfdfd2e4dc05b9c89b81efe98.tar.bz2 |
reset: socfpga: add error handling and release mem-region
In case of an error, call release_mem_region when an error happens
during allocation of resources. Also add error handling for the case
that reset_controller_register fails.
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Diffstat (limited to 'drivers/reset')
-rw-r--r-- | drivers/reset/reset-socfpga.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c index bdd984296196..2a72f861f798 100644 --- a/drivers/reset/reset-socfpga.c +++ b/drivers/reset/reset-socfpga.c @@ -44,7 +44,7 @@ static int a10_reset_init(struct device_node *np) data->membase = ioremap(res.start, size); if (!data->membase) { ret = -ENOMEM; - goto err_alloc; + goto release_region; } if (of_property_read_u32(np, "altr,modrst-offset", ®_offset)) @@ -59,7 +59,14 @@ static int a10_reset_init(struct device_node *np) data->rcdev.of_node = np; data->status_active_low = true; - return reset_controller_register(&data->rcdev); + ret = reset_controller_register(&data->rcdev); + if (ret) + pr_err("unable to register device\n"); + + return ret; + +release_region: + release_mem_region(res.start, size); err_alloc: kfree(data); |