IB: Fix ib_umem_get() when npages == 0
authorAndrew Morton <akpm@linux-foundation.org>
Fri, 8 Jun 2007 23:29:43 +0000 (16:29 -0700)
committerRoland Dreier <rolandd@cisco.com>
Mon, 9 Jul 2007 23:17:33 +0000 (16:17 -0700)
gcc correctly warned:

drivers/infiniband/core/umem.c: In function 'ib_umem_get':
drivers/infiniband/core/umem.c:78: warning: 'ret' may be used uninitialized in this function

Set ret to 0 in case npages == 0 and the loop isn't entered at all.

Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/core/umem.c

index d40652a801511b597b17de382c243d6d45adc3ef..26d0470eef6ec2c2a3abb706c821cc23437e26c1 100644 (file)
@@ -121,6 +121,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
 
        cur_base = addr & PAGE_MASK;
 
+       ret = 0;
        while (npages) {
                ret = get_user_pages(current, current->mm, cur_base,
                                     min_t(int, npages,