IB/mthca: Fix off-by-one in FMR handling on memfree
commit59d2b001518d200ba99d213e41c892f5fe750d07
authorMichael S. Tsirkin <mst@mellanox.co.il>
Sun, 11 Mar 2007 06:37:12 +0000 (11 07:37 +0100)
committerAdrian Bunk <bunk@stusta.de>
Sun, 11 Mar 2007 06:37:12 +0000 (11 07:37 +0100)
tree3bc1a37fa6c2810962111f0db21d77f54b473f8a
parent4b3c56f0239d50fff032d3ff53f7b7509d10b53b
IB/mthca: Fix off-by-one in FMR handling on memfree

From: Michael S. Tsirkin <mst@mellanox.co.il>

mthca_table_find() will return the wrong address when the table entry
being searched for is exactly at the beginning of a sglist entry
(other than the first), because it uses >= when it should use >.

Example: assume we have 2 entries in scatterlist, 4K each, offset is 4K.
The current code will return first entry + 4K when we really want
the second entry.

In particular this means mapping an FMR on a memfree HCA may end up
writing the page table into the wrong place, leading to memory
corruption and also causing the HCA to use an incorrect address
translation table.

Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Signed-off-by: Adrian Bunk <bunk@stusta.de>
drivers/infiniband/hw/mthca/mthca_memfree.c