Hello Kent Overstreet,
The patch e0750d947352: "bcachefs: Initial commit" from Mar 16, 2017
(linux-next), leads to the following Smatch static checker warning:
fs/bcachefs/checksum.c:162 bch2_chacha_encrypt_key()
warn: 'chacha20' is an error pointer or valid
fs/bcachefs/checksum.c
155 int bch2_chacha_encrypt_key(struct bch_key *key, struct nonce nonce,
156 void *buf, size_t len)
157 {
158 struct crypto_sync_skcipher *chacha20 =
159 crypto_alloc_sync_skcipher("chacha20", 0, 0);
160 int ret;
161
--> 162 if (!chacha20) {
Should be if (IS_ERR(chacha20)) {
163 pr_err("error requesting chacha20 module: %li",
PTR_ERR(chacha20));
164 return PTR_ERR(chacha20);
165 }
166
167 ret = crypto_skcipher_setkey(&chacha20->base,
168 (void *) key, sizeof(*key));
169 if (ret) {
170 pr_err("crypto_skcipher_setkey() error: %i", ret);
171 goto err;
172 }
173
174 ret = do_encrypt(chacha20, nonce, buf, len);
175 err:
176 crypto_free_sync_skcipher(chacha20);
177 return ret;
178 }
regards,
dan carpenter