提交 a844b43c 编写于 作者: A Axel Lin 提交者: Linus Torvalds

drivers/misc/atmel_tclib.c: fix a memory leak

request_mem_region() will call kzalloc to allocate memory for struct
resource.  release_resource() unregisters the resource but does not free
the allocated memory, thus use release_mem_region() instead to fix the
memory leak.
Signed-off-by: NAxel Lin <axel.lin@gmail.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 6f7d485e
...@@ -75,7 +75,7 @@ struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name) ...@@ -75,7 +75,7 @@ struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name)
return tc; return tc;
fail_ioremap: fail_ioremap:
release_resource(r); release_mem_region(r->start, ATMEL_TC_IOMEM_SIZE);
fail: fail:
tc = NULL; tc = NULL;
goto out; goto out;
...@@ -95,7 +95,7 @@ void atmel_tc_free(struct atmel_tc *tc) ...@@ -95,7 +95,7 @@ void atmel_tc_free(struct atmel_tc *tc)
spin_lock(&tc_list_lock); spin_lock(&tc_list_lock);
if (tc->regs) { if (tc->regs) {
iounmap(tc->regs); iounmap(tc->regs);
release_resource(tc->iomem); release_mem_region(tc->iomem->start, ATMEL_TC_IOMEM_SIZE);
tc->regs = NULL; tc->regs = NULL;
tc->iomem = NULL; tc->iomem = NULL;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册