[PATCH] pstore/platform: build fix when crypto API are disabled

From: Matteo Croce
Date: Mon Jul 06 2020 - 19:40:58 EST


From: Matteo Croce <mcroce@xxxxxxxxxxxxx>

When building a kernel with CONFIG_PSTORE=y and CONFIG_CRYPTO not set,
a build error happens:

ld: fs/pstore/platform.o: in function `pstore_dump':
platform.c:(.text+0x3f9): undefined reference to `crypto_comp_compress'
ld: fs/pstore/platform.o: in function `pstore_get_backend_records':
platform.c:(.text+0x784): undefined reference to `crypto_comp_decompress'

This because some pstore code uses crypto_comp_(de)compress
regardless of the CONFIG_CRYPTO status.
Fix it by wrapping the (de)compress usage by IS_ENABLED(CONFIG_PSTORE_COMPRESS)

Signed-off-by: Matteo Croce <mcroce@xxxxxxxxxxxxx>
---
fs/pstore/platform.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index a9e297eefdff..6022d8359f96 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -436,7 +436,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
dst_size, &dump_size))
break;

- if (big_oops_buf) {
+ if (IS_ENABLED(CONFIG_PSTORE_COMPRESS) && big_oops_buf) {
zipped_len = pstore_compress(dst, psinfo->buf,
header_size + dump_size,
psinfo->bufsize);
@@ -668,7 +668,7 @@ static void decompress_record(struct pstore_record *record)
int unzipped_len;
char *unzipped, *workspace;

- if (!record->compressed)
+ if (!IS_ENABLED(CONFIG_PSTORE_COMPRESS) || !record->compressed)
return;

/* Only PSTORE_TYPE_DMESG support compression. */
--
2.26.2