Commit 75e0c478 authored by Kent Overstreet's avatar Kent Overstreet
Browse files

bcachefs: Fix error checks in bch2_chacha_encrypt_key()



crypto_alloc_sync_skcipher() returns an ERR_PTR, not NULL.

Reported-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent a55fc65e
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -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;
	}