Skip to content

Commit

Permalink
[PATCH] IB: fix potential ib_umad leak
Browse files Browse the repository at this point in the history
Free all unclaimed MAD receive buffers when userspace closes our file so we
don't leak memory.

Signed-off-by: Roland Dreier <roland@topspin.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Roland Dreier authored and Linus Torvalds committed May 25, 2005
1 parent e4f50f0 commit 561e148
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/infiniband/core/user_mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
static int ib_umad_close(struct inode *inode, struct file *filp)
{
struct ib_umad_file *file = filp->private_data;
struct ib_umad_packet *packet, *tmp;
int i;

for (i = 0; i < IB_UMAD_MAX_AGENTS; ++i)
Expand All @@ -507,6 +508,9 @@ static int ib_umad_close(struct inode *inode, struct file *filp)
ib_unregister_mad_agent(file->agent[i]);
}

list_for_each_entry_safe(packet, tmp, &file->recv_list, list)
kfree(packet);

kfree(file);

return 0;
Expand Down

0 comments on commit 561e148

Please sign in to comment.