mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mips: txx9: fix resource leak after register fail
@ 2018-09-05  7:41 Ding Xiang
  2018-09-05  9:50 ` Sergei Shtylyov
  0 siblings, 1 reply; 2+ messages in thread
From: Ding Xiang @ 2018-09-05  7:41 UTC (permalink / raw)
  To: ralf, paul.burton, jhogan, linux-mips, linux-kernel; +Cc: dingxiang

the memory allocated and ioremap address need free after
device_register return error.

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

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index f6d9182..7f4fd2b 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -961,11 +961,13 @@ 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);
+exit_free:
+	iounmap(dev->base);
+	kfree(dev);
 	return;
 }
-- 
1.9.1




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-09-05  9:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-05  7:41 [PATCH] mips: txx9: fix resource leak after register fail Ding Xiang
2018-09-05  9:50 ` Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®