From: Jason Gunthorpe <jgg@ziepe.ca>
To: kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] RDMA/bnxt_re: fix a size calculation
Date: Mon, 14 Jan 2019 21:06:11 +0000 [thread overview]
Message-ID: <20190114210611.GA13596@ziepe.ca> (raw)
In-Reply-To: <20190110130019.GA27017@kadam>
On Thu, Jan 10, 2019 at 04:00:19PM +0300, Dan Carpenter wrote:
> This is from static analysis not from testing. Depending on the value
> of rcfw->cmdq_depth, then this might not cause an issue at runtime.
>
> The BITS_TO_LONGS() macro tells us how many longs it take to hold a
> bitmap. In other words, it divides by the number if bits per long and
> rounds up. Then we want to take that number and multiple by
> sizeof(long) to get the number of bytes to allocate.
>
> The code here does the multiplication first so the rounding up is done
> in the wrong place. So imagine we want to allocate 1 bit, then
> "(1 * 8) / 64 = 1" when we round up. But it should be
> "(1 / 64) * 8 = 8". In other words, because of the rounding difference
> we might allocate up to "sizeof(long) - 1" bytes fewer than intended.
>
> Fixes: 1ac5a4047975 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Acked-By: Devesh Sharma <devesh.sharma@broadcom.com>
> ---
> drivers/infiniband/hw/bnxt_re/qplib_rcfw.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
Applied to for-next
Thanks,
Jason
prev parent reply other threads:[~2019-01-14 21:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-10 13:00 [PATCH] RDMA/bnxt_re: fix a size calculation Dan Carpenter
2019-01-14 10:30 ` Devesh Sharma
2019-01-14 21:06 ` Jason Gunthorpe [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=20190114210611.GA13596@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=kernel-janitors@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