[Skiboot] [PATCH 3/4] libflash/ipmi-hiomap: Use error codes rather than abort()

Andrew Jeffery andrew at aj.id.au
Thu Nov 1 23:47:26 AEDT 2018


Admittedly the situations are pretty dire, and usually indicate a
programming failure on the BMC's part, but abort() seems a bit over the
top. The technique was useful for development but shouldn't have made it
into production.

Signed-off-by: Andrew Jeffery <andrew at aj.id.au>
---
 libflash/ipmi-hiomap.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/libflash/ipmi-hiomap.c b/libflash/ipmi-hiomap.c
index b08e72b27f37..9b5b8bdca72e 100644
--- a/libflash/ipmi-hiomap.c
+++ b/libflash/ipmi-hiomap.c
@@ -137,14 +137,16 @@ static void ipmi_hiomap_cmd_cb(struct ipmi_msg *msg)
 		if (msg->resp_size != 6) {
 			prerror("%u: Unexpected response size: %u\n", msg->data[0],
 				msg->resp_size);
-			abort();
+			res->cc = IPMI_ERR_UNSPECIFIED;
+			break;
 		}
 
 		ctx->version = msg->data[2];
 		if (ctx->version < 2) {
 			prerror("Failed to negotiate protocol v2 or higher: %d\n",
 				ctx->version);
-			abort();
+			res->cc = IPMI_ERR_UNSPECIFIED;
+			break;
 		}
 
 		parms = (struct hiomap_v2_info *)&msg->data[3];
@@ -159,7 +161,8 @@ static void ipmi_hiomap_cmd_cb(struct ipmi_msg *msg)
 		if (msg->resp_size != 6) {
 			prerror("%u: Unexpected response size: %u\n", msg->data[0],
 				msg->resp_size);
-			abort();
+			res->cc = IPMI_ERR_UNSPECIFIED;
+			break;
 		}
 
 		parms = (struct hiomap_v2_flash_info *)&msg->data[2];
@@ -177,7 +180,8 @@ static void ipmi_hiomap_cmd_cb(struct ipmi_msg *msg)
 		if (msg->resp_size != 8) {
 			prerror("%u: Unexpected response size: %u\n", msg->data[0],
 				msg->resp_size);
-			abort();
+			res->cc = IPMI_ERR_UNSPECIFIED;
+			break;
 		}
 
 		parms = (struct hiomap_v2_create_window *)&msg->data[2];
@@ -316,7 +320,7 @@ static bool hiomap_window_move(struct ipmi_hiomap *ctx, uint8_t command,
 	if (len != 0 && *size == 0) {
 		prerror("Invalid window properties: len: %llu, size: %llu\n",
 			len, *size);
-		abort();
+		return false;
 	}
 
 	prlog(PR_DEBUG, "Opened %s window from 0x%x for %u bytes at 0x%x\n",
@@ -806,7 +810,7 @@ static int ipmi_hiomap_get_flash_info(struct blocklevel_device *bl,
 		return rc;
 
 	if (!hiomap_get_flash_info(ctx)) {
-		abort();
+		return FLASH_ERR_DEVICE_GONE;
 	}
 
 	ctx->bl.erase_mask = ctx->erase_granule - 1;
-- 
2.19.1



More information about the Skiboot mailing list