diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-09-19 22:20:25 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:10:14 -0400 |
commit | 75e0c4789b623db0abae497160202bc5f5d2522e (patch) | |
tree | 4a7b79f468f06f0681889f277a84c20b84a341f8 /fs/bcachefs/checksum.c | |
parent | a55fc65eb2c71da5d422937db767a78c6438f9b6 (diff) | |
download | linux-75e0c4789b623db0abae497160202bc5f5d2522e.tar.gz linux-75e0c4789b623db0abae497160202bc5f5d2522e.tar.bz2 linux-75e0c4789b623db0abae497160202bc5f5d2522e.zip |
bcachefs: Fix error checks in bch2_chacha_encrypt_key()
crypto_alloc_sync_skcipher() returns an ERR_PTR, not NULL.
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/checksum.c')
-rw-r--r-- | fs/bcachefs/checksum.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/bcachefs/checksum.c b/fs/bcachefs/checksum.c index 3f385d499026..c70262b7fd6e 100644 --- a/fs/bcachefs/checksum.c +++ b/fs/bcachefs/checksum.c @@ -159,15 +159,16 @@ int bch2_chacha_encrypt_key(struct bch_key *key, struct nonce nonce, crypto_alloc_sync_skcipher("chacha20", 0, 0); int ret; - if (!chacha20) { - pr_err("error requesting chacha20 module: %li", PTR_ERR(chacha20)); - return PTR_ERR(chacha20); + ret = PTR_ERR_OR_ZERO(chacha20); + if (ret) { + pr_err("error requesting chacha20 cipher: %s", bch2_err_str(ret)); + return ret; } ret = crypto_skcipher_setkey(&chacha20->base, (void *) key, sizeof(*key)); if (ret) { - pr_err("crypto_skcipher_setkey() error: %i", ret); + pr_err("error from crypto_skcipher_setkey(): %s", bch2_err_str(ret)); goto err; } @@ -578,7 +579,7 @@ int bch2_decrypt_sb_key(struct bch_fs *c, /* decrypt real key: */ ret = bch2_chacha_encrypt_key(&user_key, bch2_sb_key_nonce(c), - &sb_key, sizeof(sb_key)); + &sb_key, sizeof(sb_key)); if (ret) goto err; |