Registering a zero length buffer is meaningless so check this at
ib_umem_get() and return immediately with error if that is the case.
If we don't do this, we get an inconsistent behaviour. For example,
if we register a buffer whose start address is not page aligned, we
will end up registering one page, while if the address is page
aligned, we will have zero pages -- the reason for this comes from
the following statement:

npages = PAGE_ALIGN(size + umem->offset) >> PAGE_SHIFT;

Problem found by: Ronni Zimmermann <[EMAIL PROTECTED]>
Signed-off-by: Eli Cohen <[EMAIL PROTECTED]>
---
 drivers/infiniband/core/umem.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 6f7c096..2541ef8 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -89,6 +89,9 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, 
unsigned long addr,
        int i;
        DEFINE_DMA_ATTRS(attrs);
 
+       if (!size)
+               return ERR_PTR(-ENOMEM);
+
        if (dmasync)
                dma_set_attr(DMA_ATTR_WRITE_BARRIER, &attrs);
 
-- 
1.5.6

_______________________________________________
general mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general

To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general

Reply via email to