From: Eli Cohen <eli@dev.mellanox.co.il>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Eli Cohen <eli@mellanox.com>, Roland Dreier <roland@kernel.org>,
Sean Hefty <sean.hefty@intel.com>,
Hal Rosenstock <hal.rosenstock@gmail.com>,
linux-rdma@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] mlx5: shift wrapping bug in mlx5_ib_get_buf_offset()
Date: Sun, 10 Nov 2013 09:09:13 +0200 [thread overview]
Message-ID: <20131110070913.GA30354@mtldesk30> (raw)
In-Reply-To: <20131108095259.GK27977@elgon.mountain>
On Fri, Nov 08, 2013 at 12:52:59PM +0300, Dan Carpenter wrote:
> "page_size" is declared as u64 but the (1 << page_shift) shift will wrap
> at 32 bits.
I hope to live when this happnes :-)
I prefer to be explicit and use:
page_size = (u64)1 << page_shift;
>
> Fixes: e126ba97dba9 ('mlx5: Add driver for Mellanox Connect-IB adapters')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/infiniband/hw/mlx5/mem.c b/drivers/infiniband/hw/mlx5/mem.c
> index 3a53228..3020ec2 100644
> --- a/drivers/infiniband/hw/mlx5/mem.c
> +++ b/drivers/infiniband/hw/mlx5/mem.c
> @@ -148,7 +148,7 @@ int mlx5_ib_get_buf_offset(u64 addr, int page_shift, u32 *offset)
> u64 off_mask;
> u64 buf_off;
>
> - page_size = 1 << page_shift;
> + page_size = 1ULL << page_shift;
> page_mask = page_size - 1;
> buf_off = addr & page_mask;
> off_size = page_size >> 6;
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2013-11-10 7:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-08 9:52 [PATCH] mlx5: shift wrapping bug in mlx5_ib_get_buf_offset() Dan Carpenter
2013-11-10 7:09 ` Eli Cohen [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=20131110070913.GA30354@mtldesk30 \
--to=eli@dev.mellanox.co.il \
--cc=dan.carpenter@oracle.com \
--cc=eli@mellanox.com \
--cc=hal.rosenstock@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=roland@kernel.org \
--cc=sean.hefty@intel.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