[Skiboot] [PATCH 11/12] hw/xive: Check return value from xive_decode_vp() (CID 142343 142344)

Cyril Bur cyril.bur at au1.ibm.com
Thu Aug 3 16:45:50 AEST 2017


While it is likely that a failure of xive_decode_vp() would simply trip
an error condition later on, it makes sense to check for errors earlier
and print a (hopefully) more relevant error message.

Fixes: CID 142343 and 142344
Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
 hw/xive.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/hw/xive.c b/hw/xive.c
index b830ebe0..2f9567f8 100644
--- a/hw/xive.c
+++ b/hw/xive.c
@@ -4222,7 +4222,10 @@ static int64_t opal_xive_free_vp_block(uint64_t vp_base)
 		struct xive *x;
 		struct xive_vp *vp;
 
-		xive_decode_vp(vp_id, &blk, &idx, NULL, NULL);
+		if (!xive_decode_vp(vp_id, &blk, &idx, NULL, NULL)) {
+			prerror("XIVE: Couldn't decode VP id %u\n", vp_id);
+			return OPAL_INTERNAL_ERROR;
+		}
 		x = xive_from_pc_blk(blk);
 		if (!x) {
 			prerror("XIVE: Instance not found for deallocated VP"
@@ -4289,7 +4292,10 @@ static int64_t opal_xive_alloc_vp_block(uint32_t alloc_order)
 		struct xive *x;
 		struct xive_vp *vp;
 
-		xive_decode_vp(vp_id, &blk, &idx, NULL, NULL);
+		if (!xive_decode_vp(vp_id, &blk, &idx, NULL, NULL)) {
+			prerror("XIVE: Couldn't decode VP id %u\n", vp_id);
+			return OPAL_INTERNAL_ERROR;
+		}
 		x = xive_from_pc_blk(blk);
 		if (!x) {
 			prerror("XIVE: Instance not found for allocated VP"
-- 
2.13.3



More information about the Skiboot mailing list