Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 561e148e authored by Roland Dreier's avatar Roland Dreier Committed by Linus Torvalds
Browse files

[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: default avatarRoland Dreier <roland@topspin.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e4f50f00
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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)
@@ -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;