[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>

authored by Roland Dreier and committed by Linus Torvalds 561e148e e4f50f00

+4
+4
drivers/infiniband/core/user_mad.c
··· 499 499 static int ib_umad_close(struct inode *inode, struct file *filp) 500 500 { 501 501 struct ib_umad_file *file = filp->private_data; 502 + struct ib_umad_packet *packet, *tmp; 502 503 int i; 503 504 504 505 for (i = 0; i < IB_UMAD_MAX_AGENTS; ++i) ··· 507 506 ib_dereg_mr(file->mr[i]); 508 507 ib_unregister_mad_agent(file->agent[i]); 509 508 } 509 + 510 + list_for_each_entry_safe(packet, tmp, &file->recv_list, list) 511 + kfree(packet); 510 512 511 513 kfree(file); 512 514