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

Message ID 20170803064551.3439-11-cyril.bur@au1.ibm.com
State Accepted
Headers show

Commit Message

Cyril Bur Aug. 3, 2017, 6:45 a.m.
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@au1.ibm.com>
---
 hw/xive.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Patch

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"