From 925f7ea7a6ba2d434f01662a4171867c26bda66a Mon Sep 17 00:00:00 2001 From: Leon Romanovsky Date: Sun, 28 Jan 2018 11:25:33 +0200 Subject: [PATCH] RDMA/cm: Fix access to uninitialized variable The ndev will be initialized and held only for successful ib_get_cached_gid(), otherwise it is garbage stack memory. Calling dev_put() in failure path is wrong. Fixes: 16c72e402867 ("IB/cm: Refactor to avoid setting path record software only fields") Signed-off-by: Parav Pandit Signed-off-by: Leon Romanovsky Reviewed-by: Yuval Shaia Signed-off-by: Jason Gunthorpe --- drivers/infiniband/core/cm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c index 68df93558d80..e6749157fd86 100644 --- a/drivers/infiniband/core/cm.c +++ b/drivers/infiniband/core/cm.c @@ -1901,8 +1901,6 @@ static int cm_req_handler(struct cm_work *work) grh->sgid_index, &gid, &gid_attr); if (ret) { - if (gid_attr.ndev) - dev_put(gid_attr.ndev); ib_send_cm_rej(cm_id, IB_CM_REJ_UNSUPPORTED, NULL, 0, NULL, 0); goto rejected; } -- 2.30.2