Commit 8de1d8f4 authored by GUO Zihua's avatar GUO Zihua Committed by Zheng Zengkai
Browse files

pgp: Check result of crypto_alloc_shash properly

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5Z7MD


CVE: NA

--------------------------------

Return of crypto_alloc_shash would be either a valid pointer or an error
pointer. We should check the result with IS_ERR.

Signed-off-by: default avatarGUO Zihua <guozihua@huawei.com>
Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent ef16aa34
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ static int pgp_generate_fingerprint(struct pgp_key_data_parse_context *ctx,
	ret = -ENOMEM;
	tfm = crypto_alloc_shash(pgp->version < PGP_KEY_VERSION_4 ?
				 "md5" : "sha1", 0, 0);
	if (!tfm)
	if (IS_ERR(tfm))
		goto cleanup;

	digest = kmalloc(sizeof(*digest) + crypto_shash_descsize(tfm),