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 1ECE826AC1; Sun, 1 Sep 2024 17:06:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725210391; cv=none; b=GvLfqtLAabsWnTCvuAX1OOhxv4i+rd+0Cr24iG5YJ9EiTbbIvzNcxUAop60qIdaqhITG18QPYFLNqnDB5AH6wBFI5xSv9MWxqQi6s4I3NYCFm7TYt+HhfH3Q6ZsnpLEi2vcvYCjLLXA+SpSWdQjbi0JMJUZAg/Xd3XnnKQDUTY0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725210391; c=relaxed/simple; bh=Hm73v/T98UEZh3MaInnmFEYiJ/Dt+zG1Lp1bQMpAdu8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UdN5y/9Zyrh0v1ACQ5kBv32//SZPEOTm6gONtkDa2maDcm6edOXLdujHLl1iJUE4gdBEqa+bnRH5G336GGXsRW5l+wtbr1su5WcKLO4lrMLICwNRMYqfMlFa1P4kkWXOdHb+6VeOFO7BGDeSrE/me6fcMfONAVtagzLNBvtloaM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hPDOF/Rm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="hPDOF/Rm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 821F2C4CEC3; Sun, 1 Sep 2024 17:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725210391; bh=Hm73v/T98UEZh3MaInnmFEYiJ/Dt+zG1Lp1bQMpAdu8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hPDOF/Rm3X7LsO4opeHrtcH/oCz+VOSaxMA0GKKyNo5a/93Ma9QXiTj/vgtqHrLRp BOg5VOEZ8shWgItfAuGCXThvtj5jqjorPKnT0NUJcxdSxcmM3hPLB/Lv8wSo6+bZBV jks1gV47A2T9p3QTDFGuR8/15jKWMj8Ib7QyA3Es= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Simon Horman , Ioana Ciornei , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 144/215] dpaa2-switch: Fix error checking in dpaa2_switch_seed_bp() Date: Sun, 1 Sep 2024 18:17:36 +0200 Message-ID: <20240901160828.809753201@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240901160823.230213148@linuxfoundation.org> References: <20240901160823.230213148@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit c50e7475961c36ec4d21d60af055b32f9436b431 ] The dpaa2_switch_add_bufs() function returns the number of bufs that it was able to add. It returns BUFS_PER_CMD (7) for complete success or a smaller number if there are not enough pages available. However, the error checking is looking at the total number of bufs instead of the number which were added on this iteration. Thus the error checking only works correctly for the first iteration through the loop and subsequent iterations are always counted as a success. Fix this by checking only the bufs added in the current iteration. Fixes: 0b1b71370458 ("staging: dpaa2-switch: handle Rx path on control interface") Signed-off-by: Dan Carpenter Reviewed-by: Simon Horman Reviewed-by: Ioana Ciornei Tested-by: Ioana Ciornei Link: https://patch.msgid.link/eec27f30-b43f-42b6-b8ee-04a6f83423b6@stanley.mountain Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 175f15c46842e..2b6a6a997d75e 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -2585,13 +2585,14 @@ static int dpaa2_switch_refill_bp(struct ethsw_core *ethsw) static int dpaa2_switch_seed_bp(struct ethsw_core *ethsw) { - int *count, i; + int *count, ret, i; for (i = 0; i < DPAA2_ETHSW_NUM_BUFS; i += BUFS_PER_CMD) { + ret = dpaa2_switch_add_bufs(ethsw, ethsw->bpid); count = ðsw->buf_count; - *count += dpaa2_switch_add_bufs(ethsw, ethsw->bpid); + *count += ret; - if (unlikely(*count < BUFS_PER_CMD)) + if (unlikely(ret < BUFS_PER_CMD)) return -ENOMEM; } -- 2.43.0