lkml.org 
[lkml]   [2018]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH V2] mips: txx9: fix resource leak after register fail
Date
the memory allocated and ioremap address need free after
device_register return error.

v2: remove redundant "return"

Signed-off-by: Ding Xiang <dingxiang@cmss.chinamobile.com>
---
arch/mips/txx9/generic/setup.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index f6d9182..e116a55 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -961,11 +961,12 @@ void __init txx9_sramc_init(struct resource *r)
err = sysfs_create_bin_file(&dev->dev.kobj, &dev->bindata_attr);
if (err) {
device_unregister(&dev->dev);
- iounmap(dev->base);
- kfree(dev);
+ goto exit_free;
}
return;
exit_put:
put_device(&dev->dev);
- return;
+exit_free:
+ iounmap(dev->base);
+ kfree(dev);
}
--
1.9.1


\
 
 \ /
  Last update: 2018-09-05 13:23    [W:0.038 / U:0.732 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site