From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47C22C433FE for ; Tue, 15 Nov 2022 10:24:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229660AbiKOKYL (ORCPT ); Tue, 15 Nov 2022 05:24:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229634AbiKOKYK (ORCPT ); Tue, 15 Nov 2022 05:24:10 -0500 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE4161F9F3 for ; Tue, 15 Nov 2022 02:24:09 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1668507847; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3gBWndsAywsNeFNGw3BysgXyFmtMAqbTGaKsaICV1+I=; b=RxioBAsMkEc1/tFs0I6Vgb/WN0Vkhrub7yiD8BQcjhLULUpvzAiQp6HVS2Ut7qwpzSg5nW CJ49dkPp3vB2AMFL5AD/Fa1LXJ3tqRnA6HKJzibu2r3iNhk+D+eE/GJSiEytG8+i+TkVTC FpdEa6HuVJpvk4fDNwjtCq4jQ5EkZEc= From: Guoqing Jiang Subject: Re: [PATCH RFC 02/12] RDMA/rtrs-srv: Refactor rtrs_srv_rdma_cm_handler To: Haris Iqbal Cc: jinpu.wang@ionos.com, jgg@ziepe.ca, leon@kernel.org, linux-rdma@vger.kernel.org References: <20221113010823.6436-1-guoqing.jiang@linux.dev> <20221113010823.6436-3-guoqing.jiang@linux.dev> Message-ID: <91d969ea-138d-b688-0c75-1d8ddfc2918e@linux.dev> Date: Tue, 15 Nov 2022 18:24:06 +0800 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On 11/14/22 10:39 PM, Haris Iqbal wrote: > On Sun, Nov 13, 2022 at 2:08 AM Guoqing Jiang wrote: >> The RDMA_CM_EVENT_CONNECT_REQUEST is quite different to other types, >> let's checking it separately at the beginning of routine, then we can >> avoid the identation accordingly. >> >> Signed-off-by: Guoqing Jiang >> --- >> drivers/infiniband/ulp/rtrs/rtrs-srv.c | 17 ++++++----------- >> 1 file changed, 6 insertions(+), 11 deletions(-) >> >> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c >> index 79504aaef0cc..2cc8b423bcaa 100644 >> --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c >> +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c >> @@ -1948,24 +1948,19 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, >> static int rtrs_srv_rdma_cm_handler(struct rdma_cm_id *cm_id, >> struct rdma_cm_event *ev) >> { >> - struct rtrs_srv_path *srv_path = NULL; >> - struct rtrs_path *s = NULL; >> - >> - if (ev->event != RDMA_CM_EVENT_CONNECT_REQUEST) { >> - struct rtrs_con *c = cm_id->context; >> - >> - s = c->path; >> - srv_path = to_srv_path(s); >> - } >> + struct rtrs_con *c = cm_id->context; >> + struct rtrs_path *s = c->path; >> + struct rtrs_srv_path *srv_path = to_srv_path(s); > This isn't correct for the RDMA_CM_EVENT_CONNECT_REQUEST event. At > that moment, cm_id->context is still holding a pointer to struct > rtrs_srv_ctx. Even though it never gets used for this event here, its > not right IMO to dereference in this incorrect manner. But rtrs_rdma_connect will deference the context again for connect request. > How about we move the check for the RDMA_CM_EVENT_CONNECT_REQUEST > event outside (just like you did), but let the pointers be NULL, and > only dereference after the if condition for > RDMA_CM_EVENT_CONNECT_REQUEST event? Ok, will do it though it need more lines which I tried to avoid. Thanks, Guoqing