aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/core
diff options
context:
space:
mode:
authorRoland Dreier <roland@topspin.com>2005-05-25 15:31:30 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-25 18:31:28 -0400
commit561e148ea972a6e8d2c8f7aecc658b3a64f7a6de (patch)
tree39feb619de4a5e6b6a3695082e44398c6140699f /drivers/infiniband/core
parente4f50f003dc568f6fc3904d451c562007bd09640 (diff)
[PATCH] IB: fix potential ib_umad leak
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>
Diffstat (limited to 'drivers/infiniband/core')
-rw-r--r--drivers/infiniband/core/user_mad.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 56b9c2fa2ecc..9d912d6877ff 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -499,6 +499,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
499static int ib_umad_close(struct inode *inode, struct file *filp) 499static int ib_umad_close(struct inode *inode, struct file *filp)
500{ 500{
501 struct ib_umad_file *file = filp->private_data; 501 struct ib_umad_file *file = filp->private_data;
502 struct ib_umad_packet *packet, *tmp;
502 int i; 503 int i;
503 504
504 for (i = 0; i < IB_UMAD_MAX_AGENTS; ++i) 505 for (i = 0; i < IB_UMAD_MAX_AGENTS; ++i)
@@ -507,6 +508,9 @@ static int ib_umad_close(struct inode *inode, struct file *filp)
507 ib_unregister_mad_agent(file->agent[i]); 508 ib_unregister_mad_agent(file->agent[i]);
508 } 509 }
509 510
511 list_for_each_entry_safe(packet, tmp, &file->recv_list, list)
512 kfree(packet);
513
510 kfree(file); 514 kfree(file);
511 515
512 return 0; 516 return 0;