mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-02 07:04:24 +00:00
selinux: fix bad cleanup on error in hashtab_duplicate()
commit6254bd3db3
upstream. 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:c7c556f1e8
("selinux: refactor changing booleans") Reported-by: Wander Lairson Costa <wander@redhat.com> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e085354dde
commit
0f71433eb7
1 changed files with 2 additions and 1 deletions
|
@ -178,7 +178,8 @@ int hashtab_duplicate(struct hashtab *new, struct hashtab *orig,
|
||||||
kmem_cache_free(hashtab_node_cachep, cur);
|
kmem_cache_free(hashtab_node_cachep, cur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
kmem_cache_free(hashtab_node_cachep, new);
|
kfree(new->htable);
|
||||||
|
memset(new, 0, sizeof(*new));
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue