Skip to content

Commit

Permalink
pstore: Fix linking when crypto API disabled
Browse files Browse the repository at this point in the history
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 <[email protected]>
Link: https://lore.kernel.org/lkml/[email protected]
Fixes: cb3bee0 ("pstore: Use crypto compress API")
Cc: [email protected]
Signed-off-by: Kees Cook <[email protected]>
  • Loading branch information
Matteo Croce authored and kees committed Jul 7, 2020
1 parent 4877846 commit fd49e03
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/pstore/platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ static int pstore_compress(const void *in, void *out,
{
int ret;

if (!IS_ENABLED(CONFIG_PSTORE_COMPRESSION))
return -EINVAL;

ret = crypto_comp_compress(tfm, in, inlen, out, &outlen);
if (ret) {
pr_err("crypto_comp_compress failed, ret = %d!\n", ret);
Expand Down Expand Up @@ -668,7 +671,7 @@ static void decompress_record(struct pstore_record *record)
int unzipped_len;
char *unzipped, *workspace;

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

/* Only PSTORE_TYPE_DMESG support compression. */
Expand Down

0 comments on commit fd49e03

Please sign in to comment.