From patchwork Sun Nov 13 01:08:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guoqing Jiang X-Patchwork-Id: 13041399 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 D0ADAC4332F for ; Sun, 13 Nov 2022 01:08:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235067AbiKMBIv (ORCPT ); Sat, 12 Nov 2022 20:08:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235078AbiKMBIs (ORCPT ); Sat, 12 Nov 2022 20:08:48 -0500 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7ECC2636 for ; Sat, 12 Nov 2022 17:08:46 -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=1668301725; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9LfXALLEmKe8jXFQsk0wosHGFnkjYLt7D/WoXlEPdP0=; b=xCWPk0KiiI3K5EYg2e9XDTsaBVU6PhomTBaPlpM+PdNSYzb1qU+xuLzNYYyABlN+Pvlvnb zYd4oNtCTyBNp7noVJ1s0U+wTDggyjflkzUXxMT64fqnFAOCxsVe1XcxHwTQCFlg494ozI e69sWyXlx0AxqvHWBgYGWv4QwyVsi60= From: Guoqing Jiang To: haris.iqbal@ionos.com, jinpu.wang@ionos.com, jgg@ziepe.ca, leon@kernel.org Cc: linux-rdma@vger.kernel.org Subject: [PATCH RFC 05/12] RDMA/rtrs-srv: Correct the checking of ib_map_mr_sg Date: Sun, 13 Nov 2022 09:08:16 +0800 Message-Id: <20221113010823.6436-6-guoqing.jiang@linux.dev> In-Reply-To: <20221113010823.6436-1-guoqing.jiang@linux.dev> References: <20221113010823.6436-1-guoqing.jiang@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org We should check with nr_sgt, also the only successful case is that all sg elements are mapped, so make it explict. Signed-off-by: Guoqing Jiang --- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c index 88eae0dcf87f..f3bf5bbb4377 100644 --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c @@ -622,8 +622,8 @@ static int map_cont_bufs(struct rtrs_srv_path *srv_path) } nr = ib_map_mr_sg(mr, sgt->sgl, nr_sgt, NULL, max_chunk_size); - if (nr < 0 || nr < sgt->nents) { - err = nr < 0 ? nr : -EINVAL; + if (nr != nr_sgt) { + err = -EINVAL; goto dereg_mr; }