treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / arch / s390 / purgatory / purgatory.c
blob0a423bcf674699f5264e1e709a325f2e0d807a87
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Purgatory code running between two kernels.
5 * Copyright IBM Corp. 2018
7 * Author(s): Philipp Rudo <prudo@linux.vnet.ibm.com>
8 */
10 #include <linux/kexec.h>
11 #include <linux/string.h>
12 #include <crypto/sha.h>
13 #include <asm/purgatory.h>
15 int verify_sha256_digest(void)
17 struct kexec_sha_region *ptr, *end;
18 u8 digest[SHA256_DIGEST_SIZE];
19 struct sha256_state sctx;
21 sha256_init(&sctx);
22 end = purgatory_sha_regions + ARRAY_SIZE(purgatory_sha_regions);
24 for (ptr = purgatory_sha_regions; ptr < end; ptr++)
25 sha256_update(&sctx, (uint8_t *)(ptr->start), ptr->len);
27 sha256_final(&sctx, digest);
29 if (memcmp(digest, purgatory_sha256_digest, sizeof(digest)))
30 return 1;
32 return 0;