From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 712B5154BF for ; Wed, 20 Sep 2023 12:16:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95574C433C9; Wed, 20 Sep 2023 12:16:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695212183; bh=bwbd/aX//AfvbQJaYMiWMjsKwv2P5ZLiz2LpLvDxQEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aDFpXmxP8PXL6Xsq2eOQTroQMir7/aV7UevpfQBDRRlnAjbu5r87673gEJYWZvUu/ 5Ta3e0xqKc5BnY1T3TQYv6z1X8cRnOtPQV3Hv1d/W5t24D/LqVelVkPXBLStCA0tVI Uh+EYq6hsjWtvq/LgHu+S4WwV7kf+Ks8izkpT6Jk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Logan Gunthorpe , renlonglong , Dave Jiang , Jon Mason Subject: [PATCH 4.19 181/273] ntb: Fix calculation ntb_transport_tx_free_entry() Date: Wed, 20 Sep 2023 13:30:21 +0200 Message-ID: <20230920112852.106906555@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230920112846.440597133@linuxfoundation.org> References: <20230920112846.440597133@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dave Jiang commit 5a7693e6bbf19b22fd6c1d2c4b7beb0a03969e2c upstream. ntb_transport_tx_free_entry() never returns 0 with the current calculation. If head == tail, then it would return qp->tx_max_entry. Change compare to tail >= head and when they are equal, a 0 would be returned. Fixes: e74bfeedad08 ("NTB: Add flow control to the ntb_netdev") Reviewed-by: Logan Gunthorpe Signed-off-by: renlonglong Signed-off-by: Dave Jiang Signed-off-by: Jon Mason Signed-off-by: Greg Kroah-Hartman --- drivers/ntb/ntb_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c @@ -2199,7 +2199,7 @@ unsigned int ntb_transport_tx_free_entry unsigned int head = qp->tx_index; unsigned int tail = qp->remote_rx_info->entry; - return tail > head ? tail - head : qp->tx_max_entry + tail - head; + return tail >= head ? tail - head : qp->tx_max_entry + tail - head; } EXPORT_SYMBOL_GPL(ntb_transport_tx_free_entry);