Skip to content

Commit ed1e52a

Browse files
hiqbal-ionosrleon
authored andcommitted
RDMA/rtrs-srv: Check return values while processing info request
While processing info request, it could so happen that the srv_path goes to CLOSING state, cause of any of the error events from RDMA. That state change should be picked up while trying to change the state in process_info_req, by checking the return value. In case the state change call in process_info_req fails, we fail the processing. We should also check the return value for rtrs_srv_path_up, since it sends a link event to the client above, and the client can fail for any reason. Fixes: 9cb8374 ("RDMA/rtrs: server: main functionality") Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com> Signed-off-by: Jack Wang <jinpu.wang@ionos.com> Signed-off-by: Grzegorz Prajsner <grzegorz.prajsner@ionos.com> Link: https://lore.kernel.org/r/20231120154146.920486-4-haris.iqbal@ionos.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
1 parent 3e44a61 commit ed1e52a

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

drivers/infiniband/ulp/rtrs/rtrs-srv.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -710,20 +710,23 @@ static void rtrs_srv_info_rsp_done(struct ib_cq *cq, struct ib_wc *wc)
710710
WARN_ON(wc->opcode != IB_WC_SEND);
711711
}
712712

713-
static void rtrs_srv_path_up(struct rtrs_srv_path *srv_path)
713+
static int rtrs_srv_path_up(struct rtrs_srv_path *srv_path)
714714
{
715715
struct rtrs_srv_sess *srv = srv_path->srv;
716716
struct rtrs_srv_ctx *ctx = srv->ctx;
717-
int up;
717+
int up, ret = 0;
718718

719719
mutex_lock(&srv->paths_ev_mutex);
720720
up = ++srv->paths_up;
721721
if (up == 1)
722-
ctx->ops.link_ev(srv, RTRS_SRV_LINK_EV_CONNECTED, NULL);
722+
ret = ctx->ops.link_ev(srv, RTRS_SRV_LINK_EV_CONNECTED, NULL);
723723
mutex_unlock(&srv->paths_ev_mutex);
724724

725725
/* Mark session as established */
726-
srv_path->established = true;
726+
if (!ret)
727+
srv_path->established = true;
728+
729+
return ret;
727730
}
728731

729732
static void rtrs_srv_path_down(struct rtrs_srv_path *srv_path)
@@ -852,7 +855,12 @@ static int process_info_req(struct rtrs_srv_con *con,
852855
goto iu_free;
853856
kobject_get(&srv_path->kobj);
854857
get_device(&srv_path->srv->dev);
855-
rtrs_srv_change_state(srv_path, RTRS_SRV_CONNECTED);
858+
err = rtrs_srv_change_state(srv_path, RTRS_SRV_CONNECTED);
859+
if (!err) {
860+
rtrs_err(s, "rtrs_srv_change_state(), err: %d\n", err);
861+
goto iu_free;
862+
}
863+
856864
rtrs_srv_start_hb(srv_path);
857865

858866
/*
@@ -861,7 +869,11 @@ static int process_info_req(struct rtrs_srv_con *con,
861869
* all connections are successfully established. Thus, simply notify
862870
* listener with a proper event if we are the first path.
863871
*/
864-
rtrs_srv_path_up(srv_path);
872+
err = rtrs_srv_path_up(srv_path);
873+
if (err) {
874+
rtrs_err(s, "rtrs_srv_path_up(), err: %d\n", err);
875+
goto iu_free;
876+
}
865877

866878
ib_dma_sync_single_for_device(srv_path->s.dev->ib_dev,
867879
tx_iu->dma_addr,

0 commit comments

Comments
 (0)