From: Jens Axboe <axboe@fb.com>
To: Heloise <os@iscas.ac.cn>, <hare@suse.com>, <jthumshirn@suse.de>,
<keith.busch@intel.com>, <ming.lei@redhat.com>,
<bianpan2016@163.com>, <dan.j.williams@intel.com>,
<sachin.s5@samsung.com>, <baoyou.xie@linaro.org>
Cc: <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drivers:block:mtip32xx:mtip32xx:change the order of null-pointer dereference validation
Date: Tue, 25 Apr 2017 23:13:43 -0700 [thread overview]
Message-ID: <10ff30ad-52c3-798b-7a3d-07ab5b2e938d@fb.com> (raw)
In-Reply-To: <1493170216-9035-1-git-send-email-os@iscas.ac.cn>
On 04/25/2017 06:30 PM, Heloise wrote:
> Signed-off-by: Heloise <os@iscas.ac.cn>
>
> mtip_async_complete() uses the variable port 'port->dd'at the begining, then
> validates null-pointer dereference of port 'unlikely(!port)'. Change the order
> of validation.
> ---
> drivers/block/mtip32xx/mtip32xx.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
> index 1d1dc11..feed61a 100644
> --- a/drivers/block/mtip32xx/mtip32xx.c
> +++ b/drivers/block/mtip32xx/mtip32xx.c
> @@ -228,10 +228,13 @@ static struct mtip_cmd *mtip_cmd_from_tag(struct driver_data *dd,
> static void mtip_async_complete(struct mtip_port *port,
> int tag, struct mtip_cmd *cmd, int status)
> {
> + if (unlikely(!port))
> + return;
> +
> struct driver_data *dd = port->dd;
> struct request *rq;
>
> - if (unlikely(!dd) || unlikely(!port))
> + if (unlikely(!dd))
> return;
Doesn't matter, since 'dd' isn't dereferenced before checking if
'port' is NULL.
--
Jens Axboe
next prev parent reply other threads:[~2017-04-26 6:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-26 1:30 Heloise
2017-04-26 6:13 ` Jens Axboe [this message]
2017-04-26 17:08 ` kbuild test robot
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=10ff30ad-52c3-798b-7a3d-07ab5b2e938d@fb.com \
--to=axboe@fb.com \
--cc=baoyou.xie@linaro.org \
--cc=bianpan2016@163.com \
--cc=dan.j.williams@intel.com \
--cc=hare@suse.com \
--cc=jthumshirn@suse.de \
--cc=keith.busch@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=os@iscas.ac.cn \
--cc=sachin.s5@samsung.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
all inboxes | Powered by JetHome®