Commit 3e4289b2 authored by Md Haris Iqbal's avatar Md Haris Iqbal Committed by Leon Romanovsky

RDMA/rtrs-clt: Reset cid to con_num - 1 to stay in bounds

In the function init_conns(), after the create_con() and create_cm() for
loop if something fails. In the cleanup for loop after the destroy tag, we
access out of bound memory because cid is set to clt_path->s.con_num.

This commits resets the cid to clt_path->s.con_num - 1, to stay in bounds
in the cleanup loop later.

Fixes: 6a98d71d ("RDMA/rtrs: client: main functionality")
Signed-off-by: default avatarMd Haris Iqbal <haris.iqbal@ionos.com>
Signed-off-by: default avatarJack Wang <jinpu.wang@ionos.com>
Signed-off-by: default avatarGrzegorz Prajsner <grzegorz.prajsner@ionos.com>
Link: https://patch.msgid.link/20240821112217.41827-7-haris.iqbal@ionos.comSigned-off-by: default avatarLeon Romanovsky <leon@kernel.org>
parent 6793f958
......@@ -2347,6 +2347,12 @@ static int init_conns(struct rtrs_clt_path *clt_path)
if (err)
goto destroy;
}
/*
* Set the cid to con_num - 1, since if we fail later, we want to stay in bounds.
*/
cid = clt_path->s.con_num - 1;
err = alloc_path_reqs(clt_path);
if (err)
goto destroy;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment