All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] bcachefs: error pointer vs NULL in bch2_chacha_encrypt_key()
@ 2023-09-15 12:56 Dan Carpenter
  2023-09-20  1:56 ` Kent Overstreet
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-09-15 12:56 UTC (permalink / raw)
  To: kent.overstreet; +Cc: Brian Foster, linux-bcachefs

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] bcachefs: error pointer vs NULL in bch2_chacha_encrypt_key()
  2023-09-15 12:56 [bug report] bcachefs: error pointer vs NULL in bch2_chacha_encrypt_key() Dan Carpenter
@ 2023-09-20  1:56 ` Kent Overstreet
  0 siblings, 0 replies; 2+ messages in thread
From: Kent Overstreet @ 2023-09-20  1:56 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: kent.overstreet, Brian Foster, linux-bcachefs

On Fri, Sep 15, 2023 at 03:56:51PM +0300, Dan Carpenter wrote:
> 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

thanks, fixed

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-20  1:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-15 12:56 [bug report] bcachefs: error pointer vs NULL in bch2_chacha_encrypt_key() Dan Carpenter
2023-09-20  1:56 ` Kent Overstreet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.