Linux cryptographic layer development
 help / color / mirror / Atom feed
* [bug report] crypto: algboss - Pass instance creation error up
@ 2024-09-11  8:08 Dan Carpenter
  2024-09-11  8:12 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2024-09-11  8:08 UTC (permalink / raw)
  To: Herbert Xu; +Cc: linux-crypto

Hello Herbert Xu,

Commit 795f85fca229 ("crypto: algboss - Pass instance creation error
up") from Sep 1, 2024 (linux-next), leads to the following Smatch
static checker warning:

	crypto/algboss.c:67 cryptomgr_probe()
	warn: passing zero to 'ERR_PTR'

crypto/algboss.c
    50 static int cryptomgr_probe(void *data)
    51 {
    52         struct cryptomgr_param *param = data;
    53         struct crypto_template *tmpl;
    54         int err = -ENOENT;
    55 
    56         tmpl = crypto_lookup_template(param->template);
    57         if (!tmpl)
    58                 goto out;
    59 
    60         do {
    61                 err = tmpl->create(tmpl, param->tb);
    62         } while (err == -EAGAIN && !signal_pending(current));
    63 
    64         crypto_tmpl_put(tmpl);
    65 
    66 out:
--> 67         param->larval->adult = ERR_PTR(err);

I wasn't able to find anything which was using this code...

This is assigned on both the success and failure paths so it means that
crypto_larval_destroy() never calls crypto_mod_put(larval->adult).  But I don't
really understand this code well so maybe there is nothing to free at this
point.

    68         param->larval->alg.cra_flags |= CRYPTO_ALG_DEAD;
    69         complete_all(&param->larval->completion);
    70         crypto_alg_put(&param->larval->alg);
    71         kfree(param);
    72         module_put_and_kthread_exit(0);
    73 }

regards,
dan carpenter

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

* Re: [bug report] crypto: algboss - Pass instance creation error up
  2024-09-11  8:08 [bug report] crypto: algboss - Pass instance creation error up Dan Carpenter
@ 2024-09-11  8:12 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2024-09-11  8:12 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-crypto

On Wed, Sep 11, 2024 at 11:08:01AM +0300, Dan Carpenter wrote:
> Hello Herbert Xu,
> 
> Commit 795f85fca229 ("crypto: algboss - Pass instance creation error
> up") from Sep 1, 2024 (linux-next), leads to the following Smatch
> static checker warning:
> 
> 	crypto/algboss.c:67 cryptomgr_probe()
> 	warn: passing zero to 'ERR_PTR'
> 
> crypto/algboss.c
>     50 static int cryptomgr_probe(void *data)
>     51 {
>     52         struct cryptomgr_param *param = data;
>     53         struct crypto_template *tmpl;
>     54         int err = -ENOENT;
>     55 
>     56         tmpl = crypto_lookup_template(param->template);
>     57         if (!tmpl)
>     58                 goto out;
>     59 
>     60         do {
>     61                 err = tmpl->create(tmpl, param->tb);
>     62         } while (err == -EAGAIN && !signal_pending(current));
>     63 
>     64         crypto_tmpl_put(tmpl);
>     65 
>     66 out:
> --> 67         param->larval->adult = ERR_PTR(err);

This is intentional.  If adult is NULL then the caller will retry
the lookup in crypto_larval_wait.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2024-09-11  8:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-11  8:08 [bug report] crypto: algboss - Pass instance creation error up Dan Carpenter
2024-09-11  8:12 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox