From: Lars Ellenberg <lars.ellenberg@linbit.com>
To: Heloise <os@iscas.ac.cn>
Cc: philipp.reisner@linbit.com, drbd-dev@lists.linbit.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers:block:drbd:drbd_state:fix null-pointer dereference
Date: Tue, 25 Apr 2017 09:06:02 +0200 [thread overview]
Message-ID: <20170425070602.GA3987@soda.linbit> (raw)
In-Reply-To: <1493102118-8086-1-git-send-email-os@iscas.ac.cn>
On Mon, Apr 24, 2017 at 11:35:18PM -0700, Heloise wrote:
> Signed-off-by: Heloise <os@iscas.ac.cn>
>
> In is_valid_state(), there is NULL validation for the variable nc
> "if (nc)". However,the code will continue to execute when nc is NULL.
> nc->verify_alg[0] is used in subsequent code, which may cause
> null-pointer dereference, fix it.
> ---
> drivers/block/drbd/drbd_state.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
> index eea0c4a..1963b83 100644
> --- a/drivers/block/drbd/drbd_state.c
> +++ b/drivers/block/drbd/drbd_state.c
> @@ -845,7 +845,7 @@ is_valid_state(struct drbd_device *device, union drbd_state ns)
> rv = SS_CONNECTED_OUTDATES;
>
> else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) &&
> - (nc->verify_alg[0] == 0))
> + (nc != NULL && nc->verify_alg[0] == 0))
What the static checker cannot know:
ns.conn != C_STANDALONE implies nc != NULL.
But if you feel like it, the additional check won't hurt.
Thanks,
Lars
prev parent reply other threads:[~2017-04-25 7:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-25 6:35 [PATCH] drivers:block:drbd:drbd_state:fix null-pointer dereference Heloise
2017-04-25 7:06 ` Lars Ellenberg [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=20170425070602.GA3987@soda.linbit \
--to=lars.ellenberg@linbit.com \
--cc=drbd-dev@lists.linbit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=os@iscas.ac.cn \
--cc=philipp.reisner@linbit.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