From patchwork Fri Jan 21 06:22:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 12719314 X-Patchwork-Delegate: leon@leon.nu 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 EF7B7C433F5 for ; Fri, 21 Jan 2022 06:23:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378682AbiAUGXa (ORCPT ); Fri, 21 Jan 2022 01:23:30 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:51365 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1343580AbiAUGX3 (ORCPT ); Fri, 21 Jan 2022 01:23:29 -0500 IronPort-Data: A9a23:Fh6DxKK0GVwcOpaxFE+RG5clxSXFcZb7ZxGrkP8bfHDq0z921TMByDNOCmzUP/vcajekeYp2OoXk8RkGv5LcyYNqS1BcGVNFFSwT8ZWfbTi6wuYcBwvLd4ubChsPA/w2MrEsF+hpCC+MzvuRGuK59yMkjPvRHuOU5NPsYUideyc1EU/Ntjozw4bVsqYw6TSIK1vlVeHa+qUzC3f5s9JACV/43orYwP9ZUFsejxtD1rA2TagjUFYzDBD5BrpHTU26ByOQroW5goeHq+j/ILGRpgs1/j8mDJWrj7T6blYXBLXVOGBiiFIPA+773EcE/Xd0j87XN9JFAatToySAmd9hjtdcnZKtSwY1JbCKk+MYO/VdO3gkZfMbp++ecBBTtuTWlSUqaUDE2e1jBVstOosY4utfDmRH9PheIzcIBjiHiuWw6LG2UO9hgoIkNsaDFIcevGxwiCvVCP8OX5/OWePJ6MVe0TN2gdpBdd7caMUxeztidBmGaBQnB7u9IPrSh8/x3j+mLWIe8wnT+MIKD6Ho5FQZ+NDQ3BD9K7Rmnfloo3s= IronPort-HdrOrdr: A9a23:tMY0cKnqt5R8YaQ+ljJ3NZ2qqLTpDfLG3DAbv31ZSRFFG/Fxl6iV/cjzsiWE7wr5OUtQ/+xoV5PwIk80maQb3WBzB8bHYOCFghrLEGgK1+KLqFeMdxEWndQ86U4PScZD4aXLfD1HZNjBkXOFOudl0N+a67qpmOub639sSDthY6Zm4xwRMHfiLmRGABlBGYEiFIeRou5Opz+bc3wRacihQlYfWeyrnayxqLvWJQ4BGwU86BSDyReh6LvBGRCe2RsEFxNjqI1SiFT4rw== X-IronPort-AV: E=Sophos;i="5.88,304,1635177600"; d="scan'208";a="120657819" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 21 Jan 2022 14:23:25 +0800 Received: from G08CNEXMBPEKD05.g08.fujitsu.local (unknown [10.167.33.204]) by cn.fujitsu.com (Postfix) with ESMTP id 4412F4D146E8; Fri, 21 Jan 2022 14:23:22 +0800 (CST) Received: from G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) by G08CNEXMBPEKD05.g08.fujitsu.local (10.167.33.204) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 21 Jan 2022 14:23:22 +0800 Received: from G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.85) by G08CNEXJMPEKD02.g08.fujitsu.local (10.167.33.202) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 21 Jan 2022 14:23:21 +0800 Received: from Fedora-31.g08.fujitsu.local (10.167.220.99) by G08CNEXCHPEKD09.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.23 via Frontend Transport; Fri, 21 Jan 2022 14:23:12 +0800 From: Xiao Yang To: CC: , , , Xiao Yang Subject: [PATCH rdma-core v2] providers/rxe: Replace '%' with '&' in check_qp_queue_full() Date: Fri, 21 Jan 2022 14:22:22 +0800 Message-ID: <20220121062222.2914007-1-yangx.jy@fujitsu.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-yoursite-MailScanner-ID: 4412F4D146E8.A4DA6 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@fujitsu.com Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org The expression "cons == ((qp->cur_index + 1) % q->index_mask)" doesn't check the state of queue (full or empty) correctly. For example: If cons and qp->cur_index are 0 and q->index_mask is 1, the queue is actually empty but check_qp_queue_full() reports full (ENOSPC). Fixes: 1a894ca10105 ("Providers/rxe: Implement ibv_create_qp_ex verb") Signed-off-by: Xiao Yang Reviewed-by: Bob Pearson --- providers/rxe/rxe_queue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/rxe/rxe_queue.h b/providers/rxe/rxe_queue.h index 6de8140c..708e76ac 100644 --- a/providers/rxe/rxe_queue.h +++ b/providers/rxe/rxe_queue.h @@ -205,7 +205,7 @@ static inline int check_qp_queue_full(struct rxe_qp *qp) if (qp->err) goto err; - if (cons == ((qp->cur_index + 1) % q->index_mask)) + if (cons == ((qp->cur_index + 1) & q->index_mask)) qp->err = ENOSPC; err: return qp->err;