From: Yu Kuai <yukuai1@huaweicloud.com>
To: Ye Chey <yechey@ai-sast.com>, song@kernel.org
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH] md: fix potential NULL pointer dereference in md_super_write
Date: Fri, 23 May 2025 17:59:09 +0800 [thread overview]
Message-ID: <daf88fa3-f87e-a0c7-b93c-a4d150be8afc@huaweicloud.com> (raw)
In-Reply-To: <20250523093554.23182-1-yechey@ai-sast.com>
Hi,
在 2025/05/23 17:35, Ye Chey 写道:
> The bio_alloc_bioset() call in md_super_write() could fail under memory
> pressure and return NULL. Add a check to handle this case gracefully by
> returning early, preventing a potential NULL pointer dereference.
NAK, if you read the comments of bio_alloc_bioset(), you'll know there
are cases bio_alloc_bioset() will never return NULL.
Thanks,
Kuai
>
> Signed-off-by: Ye Chey <yechey@ai-sast.com>
> ---
> drivers/md/md.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 9daa78c5f..a0e2d90d4 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -1002,6 +1002,8 @@ void md_super_write(struct mddev *mddev, struct md_rdev *rdev,
> REQ_OP_WRITE | REQ_SYNC | REQ_IDLE | REQ_META
> | REQ_PREFLUSH | REQ_FUA,
> GFP_NOIO, &mddev->sync_set);
> + if (!bio)
> + return;
>
> atomic_inc(&rdev->nr_pending);
>
>
next prev parent reply other threads:[~2025-05-23 9:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-23 9:35 [PATCH] md: fix potential NULL pointer dereference in md_super_write Ye Chey
2025-05-23 9:59 ` Yu Kuai [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-05-23 9:11 Ye Chey
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=daf88fa3-f87e-a0c7-b93c-a4d150be8afc@huaweicloud.com \
--to=yukuai1@huaweicloud.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=song@kernel.org \
--cc=yechey@ai-sast.com \
--cc=yukuai3@huawei.com \
/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).