> -----Original Message----- > From: Guoqing Jiang <guoqing.jiang@xxxxxxxxx> > Sent: Friday, October 27, 2023 3:27 PM > To: Bernard Metzler <BMT@xxxxxxxxxxxxxx>; jgg@xxxxxxxx; leon@xxxxxxxxxx > Cc: linux-rdma@xxxxxxxxxxxxxxx > Subject: [EXTERNAL] [PATCH V4 12/18] RDMA/siw: Introduce siw_free_cm_id > > Factor out a helper to simplify code. > > Reported-by: kernel test robot <lkp@xxxxxxxxx> > Closes: INVALID URI REMOVED > 3A__lore.kernel.org_oe-2Dkbuild-2Dall_202310091656.JlrmcNXB-2Dlkp- > 40intel.com_&d=DwIDAg&c=jf_iaSHvJObTbx-siA1ZOg&r=2TaYXQ0T- > r8ZO1PP1alNwU_QJcRRLfmYTAgd3QCvqSc&m=aD4gL7u0nROWIiFk0ch8zNX6vYWKMUOorYEWPY > b9amSqnQTH0qNMcLijHRNn7r_s&s=kmGGMztuOUMejyxISpfW94VtbHKDivS9DMunEaOx5uc&e= > Signed-off-by: Guoqing Jiang <guoqing.jiang@xxxxxxxxx> > --- > Changes since last version: > 1. add missed check of cep->cm_id > > drivers/infiniband/sw/siw/siw_cm.c | 30 ++++++++++++++---------------- > 1 file changed, 14 insertions(+), 16 deletions(-) > > diff --git a/drivers/infiniband/sw/siw/siw_cm.c > b/drivers/infiniband/sw/siw/siw_cm.c > index 2f338bb3a24c..9c79d3ea5b66 100644 > --- a/drivers/infiniband/sw/siw/siw_cm.c > +++ b/drivers/infiniband/sw/siw/siw_cm.c > @@ -364,6 +364,15 @@ static int siw_cm_upcall(struct siw_cep *cep, enum > iw_cm_event_type reason, > return id->event_handler(id, &event); > } > > +static void siw_free_cm_id(struct siw_cep *cep) > +{ > + if (!cep->cm_id) > + return; > + > + cep->cm_id->rem_ref(cep->cm_id); > + cep->cm_id = NULL; > +} > + > /* > * siw_qp_cm_drop() > * > @@ -415,8 +424,7 @@ void siw_qp_cm_drop(struct siw_qp *qp, int schedule) > default: > break; > } > - cep->cm_id->rem_ref(cep->cm_id); > - cep->cm_id = NULL; > + siw_free_cm_id(cep); > siw_cep_put(cep); > } > cep->state = SIW_EPSTATE_CLOSED; > @@ -1176,8 +1184,7 @@ static void siw_cm_work_handler(struct work_struct > *w) > cep->sock = NULL; > } > if (cep->cm_id) { > - cep->cm_id->rem_ref(cep->cm_id); > - cep->cm_id = NULL; > + siw_free_cm_id(cep); > siw_cep_put(cep); > } > } > @@ -1702,10 +1709,7 @@ int siw_accept(struct iw_cm_id *id, struct > iw_cm_conn_param *params) > > cep->state = SIW_EPSTATE_CLOSED; > > - if (cep->cm_id) { > - cep->cm_id->rem_ref(id); > - cep->cm_id = NULL; > - } > + siw_free_cm_id(cep); > if (qp->cep) { > siw_cep_put(cep); > qp->cep = NULL; > @@ -1880,10 +1884,7 @@ int siw_create_listen(struct iw_cm_id *id, int > backlog) > if (cep) { > siw_cep_set_inuse(cep); > > - if (cep->cm_id) { > - cep->cm_id->rem_ref(cep->cm_id); > - cep->cm_id = NULL; > - } > + siw_free_cm_id(cep); > cep->sock = NULL; > siw_socket_disassoc(s); > cep->state = SIW_EPSTATE_CLOSED; > @@ -1912,10 +1913,7 @@ static void siw_drop_listeners(struct iw_cm_id *id) > > siw_cep_set_inuse(cep); > > - if (cep->cm_id) { > - cep->cm_id->rem_ref(cep->cm_id); > - cep->cm_id = NULL; > - } > + siw_free_cm_id(cep); > if (cep->sock) { > siw_socket_disassoc(cep->sock); > sock_release(cep->sock); > -- > 2.35.3 Looks good. Acked-by: Bernard Metzler <bmt@xxxxxxxxxxxxxx>