Skip to content

Commit

Permalink
drivers/misc/atmel_tclib.c: fix a memory leak
Browse files Browse the repository at this point in the history
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: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Axel Lin authored and Linus Torvalds committed Mar 23, 2011
1 parent 6f7d485 commit a844b43
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/misc/atmel_tclib.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct atmel_tc *atmel_tc_alloc(unsigned block, const char *name)
return tc;

fail_ioremap:
release_resource(r);
release_mem_region(r->start, ATMEL_TC_IOMEM_SIZE);
fail:
tc = NULL;
goto out;
Expand All @@ -95,7 +95,7 @@ void atmel_tc_free(struct atmel_tc *tc)
spin_lock(&tc_list_lock);
if (tc->regs) {
iounmap(tc->regs);
release_resource(tc->iomem);
release_mem_region(tc->iomem->start, ATMEL_TC_IOMEM_SIZE);
tc->regs = NULL;
tc->iomem = NULL;
}
Expand Down

0 comments on commit a844b43

Please sign in to comment.