Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b26bdde

Browse files
tiwaiMimi Zohar
authored andcommitted
KEYS: Fix stale key registration at error path
When loading encrypted-keys module, if the last check of aes_get_sizes() in init_encrypted() fails, the driver just returns an error without unregistering its key type. This results in the stale entry in the list. In addition to memory leaks, this leads to a kernel crash when registering a new key type later. This patch fixes the problem by swapping the calls of aes_get_sizes() and register_key_type(), and releasing resources properly at the error paths. Bugzilla: https://bugzilla.opensuse.org/show_bug.cgi?id=908163 Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent b2d1965 commit b26bdde

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

security/keys/encrypted-keys/encrypted.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,10 +1017,13 @@ static int __init init_encrypted(void)
10171017
ret = encrypted_shash_alloc();
10181018
if (ret < 0)
10191019
return ret;
1020+
ret = aes_get_sizes();
1021+
if (ret < 0)
1022+
goto out;
10201023
ret = register_key_type(&key_type_encrypted);
10211024
if (ret < 0)
10221025
goto out;
1023-
return aes_get_sizes();
1026+
return 0;
10241027
out:
10251028
encrypted_shash_release();
10261029
return ret;

0 commit comments

Comments
 (0)