diff mbox

nvlink: Fix bad PE number check

Message ID 20160905062053.16160-1-ruscur@russell.cc
State Accepted
Headers show

Commit Message

Russell Currey Sept. 5, 2016, 6:20 a.m. UTC
NPUs have 4 PEs which are zero indexed, so {0, 1, 2, 3}.  A bad PE number
check in npu_err_inject checks if the PE number is greater than 4 as a
fail case, so it would wrongly perform operations on a non-existant PE 4.

Reported-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Cc: stable
Signed-off-by: Russell Currey <ruscur@russell.cc>
---
 hw/npu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stewart Smith Sept. 5, 2016, 6:44 a.m. UTC | #1
Russell Currey <ruscur@russell.cc> writes:
> NPUs have 4 PEs which are zero indexed, so {0, 1, 2, 3}.  A bad PE number
> check in npu_err_inject checks if the PE number is greater than 4 as a
> fail case, so it would wrongly perform operations on a non-existant PE 4.
>
> Reported-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> Cc: stable
> Signed-off-by: Russell Currey <ruscur@russell.cc>

looks good, merged to:
master 731d1a8d680bd0bf649cf0c4668a449e299e5f55
skiboot-5.3.x b841d26d11a637b92ca397921fd7facbb8609dfa
diff mbox

Patch

diff --git a/hw/npu.c b/hw/npu.c
index 54f9085..0682118 100644
--- a/hw/npu.c
+++ b/hw/npu.c
@@ -929,7 +929,7 @@  static int64_t npu_err_inject(struct phb *phb, uint64_t pe_number,
 	struct npu_dev *dev = NULL;
 	int i;
 
-	if (pe_number > NPU_NUM_OF_PES) {
+	if (pe_number >= NPU_NUM_OF_PES) {
 		prlog(PR_ERR, "NPU: error injection failed, bad PE given\n");
 		return OPAL_PARAMETER;
 	}