Commit c73275cf authored by Gaosheng Cui's avatar Gaosheng Cui Committed by John Johansen
Browse files

apparmor: fix a memleak in multi_transaction_new()



In multi_transaction_new(), the variable t is not freed or passed out
on the failure of copy_from_user(t->data, buf, size), which could lead
to a memleak.

Fix this bug by adding a put_multi_transaction(t) in the error path.

Fixes: 1dea3b41 ("apparmor: speed up transactional queries")
Signed-off-by: default avatarGaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
parent 3cc40a44
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -868,8 +868,10 @@ static struct multi_transaction *multi_transaction_new(struct file *file,
	if (!t)
		return ERR_PTR(-ENOMEM);
	kref_init(&t->count);
	if (copy_from_user(t->data, buf, size))
	if (copy_from_user(t->data, buf, size)) {
		put_multi_transaction(t);
		return ERR_PTR(-EFAULT);
	}

	return t;
}