RDMA/cm: Fix access to uninitialized variable
authorLeon Romanovsky <leonro@mellanox.com>
Sun, 28 Jan 2018 09:25:33 +0000 (11:25 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Sun, 28 Jan 2018 21:07:16 +0000 (14:07 -0700)
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 <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/cm.c

index 68df93558d80e362a73d0b725a1907a010e037b4..e6749157fd86c35550df617cc89b6120a29fb5d4 100644 (file)
@@ -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;
        }