From: Eric Biggers <ebiggers@kernel.org>
To: Haoxiang Li <haoxiang_li2024@163.com>
Cc: axboe@kernel.dk, satyat@google.com, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] blk-crypto: Add check for mempool_alloc()
Date: Thu, 2 Jan 2025 17:23:29 +0000 [thread overview]
Message-ID: <20250102172329.GA49952@google.com> (raw)
In-Reply-To: <20250102083319.176310-1-haoxiang_li2024@163.com>
On Thu, Jan 02, 2025 at 04:33:19PM +0800, Haoxiang Li wrote:
> Add check for the return value of mempool_alloc() to
> catch the potential exception and avoid null pointer
> dereference.
>
> Fixes: 488f6682c832 ("block: blk-crypto-fallback for Inline Encryption")
> Cc: stable@vger.kernel.org
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
> ---
> block/blk-crypto-fallback.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c
> index 29a205482617..47acd7a48767 100644
> --- a/block/blk-crypto-fallback.c
> +++ b/block/blk-crypto-fallback.c
> @@ -514,6 +514,12 @@ bool blk_crypto_fallback_bio_prep(struct bio **bio_ptr)
> * bi_end_io appropriately to trigger decryption when the bio is ended.
> */
> f_ctx = mempool_alloc(bio_fallback_crypt_ctx_pool, GFP_NOIO);
> +
> + if (!f_ctx) {
> + bio->bi_status = BLK_STS_RESOURCE;
> + return false;
> + }
mempool_alloc() with a mask that includes ___GFP_DIRECT_RECLAIM, such as the
GFP_NOIO which is used here, never returns NULL.
- Eric
prev parent reply other threads:[~2025-01-02 17:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-02 8:33 [PATCH] blk-crypto: Add check for mempool_alloc() Haoxiang Li
2025-01-02 17:23 ` 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=20250102172329.GA49952@google.com \
--to=ebiggers@kernel.org \
--cc=axboe@kernel.dk \
--cc=haoxiang_li2024@163.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=satyat@google.com \
--cc=stable@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).