RDMA/cxgb4: set error code on kmalloc() failure
authorYann Droneaud <[mailto:ydroneaud@opteya.com]>
Fri, 28 Mar 2014 18:55:21 +0000 (14:55 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 28 Mar 2014 18:55:21 +0000 (14:55 -0400)
If kmalloc() fails in c4iw_alloc_ucontext(), the function
leaves but does not set an error code in ret variable:
it will return 0 to the caller.

This patch set ret to -ENOMEM in such case.

Cc: Steve Wise <swise@opengridcomputing.com>
Cc: Steve Wise <swise@chelsio.com>
Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
Acked-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/infiniband/hw/cxgb4/provider.c

index e36d2a27c4315bfbeedd6e67dc8fba535ca82ead..79429256023a7e2e7be7f83e7f1b305233f5348a 100644 (file)
@@ -128,8 +128,10 @@ static struct ib_ucontext *c4iw_alloc_ucontext(struct ib_device *ibdev,
                rhp->rdev.flags |= T4_STATUS_PAGE_DISABLED;
        } else {
                mm = kmalloc(sizeof(*mm), GFP_KERNEL);
-               if (!mm)
+               if (!mm) {
+                       ret = -ENOMEM;
                        goto err_free;
+               }
 
                uresp.status_page_size = PAGE_SIZE;