From: Yann Droneaud <[mailto:ydroneaud@opteya.com]> Date: Fri, 28 Mar 2014 18:55:21 +0000 (-0400) Subject: RDMA/cxgb4: set error code on kmalloc() failure X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=bfd2793c9559ae73ae021797f1d4b097c27f24be;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git RDMA/cxgb4: set error code on kmalloc() failure 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 Cc: Steve Wise Signed-off-by: Yann Droneaud Acked-by: Steve Wise Signed-off-by: David S. Miller --- diff --git a/drivers/infiniband/hw/cxgb4/provider.c b/drivers/infiniband/hw/cxgb4/provider.c index e36d2a27c431..79429256023a 100644 --- a/drivers/infiniband/hw/cxgb4/provider.c +++ b/drivers/infiniband/hw/cxgb4/provider.c @@ -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;