From: Eric Biggers <ebiggers@kernel.org>
To: cgel.zte@gmail.com
Cc: davem@davemloft.net, herbert@gondor.apana.org.au,
linux-crypto@vger.kernel.org,
ye xingchen <ye.xingchen@zte.com.cn>,
Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH linux-next] crypto: api - Avoid NULL pointer dereference in crypto_larval_destroy()
Date: Tue, 16 Aug 2022 11:48:11 -0700 [thread overview]
Message-ID: <Yvvmaw70Ot0bNDdM@sol.localdomain> (raw)
In-Reply-To: <20220816113722.82894-1-ye.xingchen@zte.com.cn>
On Tue, Aug 16, 2022 at 11:37:22AM +0000, cgel.zte@gmail.com wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
>
> When we have no primary larval or when it's a software node, we may end up
> in the situation when larval is a NULL pointer. There is no point to look
> for secondary larval in such case. Add a necessary check to a condition.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> ---
> crypto/api.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/crypto/api.c b/crypto/api.c
> index 69508ae9345e..f2399aac831d 100644
> --- a/crypto/api.c
> +++ b/crypto/api.c
> @@ -96,7 +96,7 @@ static void crypto_larval_destroy(struct crypto_alg *alg)
> struct crypto_larval *larval = (void *)alg;
>
> BUG_ON(!crypto_is_larval(alg));
> - if (!IS_ERR_OR_NULL(larval->adult))
> + if (larval && !IS_ERR_OR_NULL(larval->adult))
> crypto_mod_put(larval->adult);
> kfree(larval);
> }
> --
How does this new NULL check do anything when the pointer is unconditionally
dereferenced in the previous line?
- Eric
prev parent reply other threads:[~2022-08-16 18:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-16 11:37 [PATCH linux-next] crypto: api - Avoid NULL pointer dereference in crypto_larval_destroy() cgel.zte
2022-08-16 18:48 ` Eric Biggers [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Yvvmaw70Ot0bNDdM@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=cgel.zte@gmail.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=ye.xingchen@zte.com.cn \
--cc=zealci@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox