Commit 6254bd3d authored by Ondrej Mosnacek's avatar Ondrej Mosnacek Committed by Paul Moore

selinux: fix bad cleanup on error in hashtab_duplicate()

The code attempts to free the 'new' pointer using kmem_cache_free(),
which is wrong because this function isn't responsible of freeing it.
Instead, the function should free new->htable and clear the contents of
*new (to prevent double-free).

Cc: stable@vger.kernel.org
Fixes: c7c556f1 ("selinux: refactor changing booleans")
Reported-by: default avatarWander Lairson Costa <wander@redhat.com>
Signed-off-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
parent 42226c98
......@@ -179,7 +179,8 @@ int hashtab_duplicate(struct hashtab *new, struct hashtab *orig,
kmem_cache_free(hashtab_node_cachep, cur);
}
}
kmem_cache_free(hashtab_node_cachep, new);
kfree(new->htable);
memset(new, 0, sizeof(*new));
return -ENOMEM;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment