mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-10 08:33:14 +00:00
integrity: Fix memory leakage in keyring allocation error path
[ Upstream commit39419ef7af
] Key restriction is allocated in integrity_init_keyring(). However, if keyring allocation failed, it is not freed, causing memory leaks. Fixes:2b6aa412ff
("KEYS: Use structure to capture key restriction function and data") Signed-off-by: GUO Zihua <guozihua@huawei.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
db75248653
commit
8f40de263d
1 changed files with 5 additions and 1 deletions
|
@ -122,6 +122,7 @@ int __init integrity_init_keyring(const unsigned int id)
|
||||||
{
|
{
|
||||||
struct key_restriction *restriction;
|
struct key_restriction *restriction;
|
||||||
key_perm_t perm;
|
key_perm_t perm;
|
||||||
|
int ret;
|
||||||
|
|
||||||
perm = (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_VIEW
|
perm = (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_VIEW
|
||||||
| KEY_USR_READ | KEY_USR_SEARCH;
|
| KEY_USR_READ | KEY_USR_SEARCH;
|
||||||
|
@ -142,7 +143,10 @@ int __init integrity_init_keyring(const unsigned int id)
|
||||||
perm |= KEY_USR_WRITE;
|
perm |= KEY_USR_WRITE;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return __integrity_init_keyring(id, perm, restriction);
|
ret = __integrity_init_keyring(id, perm, restriction);
|
||||||
|
if (ret)
|
||||||
|
kfree(restriction);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init integrity_add_key(const unsigned int id, const void *data,
|
static int __init integrity_add_key(const unsigned int id, const void *data,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue