summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxim Polyakov <m.polyakov@yadro.com>2019-07-08 12:13:54 +0300
committerJeremy Kerr <jk@ozlabs.org>2019-10-08 14:31:09 +0800
commit3c818a27ddb6bbc71667c7f2ceb57be37b31bc6f (patch)
tree89453d9f783342d19f9f5aae9dbdecd75192cda4
parenteb027e76d13f4fb5915cd5373e4ae78cd5905841 (diff)
downloadtalos-petitboot-3c818a27ddb6bbc71667c7f2ceb57be37b31bc6f.tar.gz
talos-petitboot-3c818a27ddb6bbc71667c7f2ceb57be37b31bc6f.zip
discover/platform-powerpc: don't copy IANA from mbox to buffer
This patch adds code that takes into account the size of the IANA identifier number in the mailbox and doesn't copy it into the data buffer Signed-off-by: Maxim Polyakov <m.polyakov@yadro.com>
-rw-r--r--discover/platform-powerpc.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
index 7b9d443..fcfe41a 100644
--- a/discover/platform-powerpc.c
+++ b/discover/platform-powerpc.c
@@ -536,6 +536,7 @@ static int get_ipmi_boot_mailbox(struct platform_powerpc *platform,
* on higher numbers.
*/
for (i = 0; i < UCHAR_MAX; i++) {
+ uint8_t *boot_opt_data;
int block_size = get_ipmi_boot_mailbox_block(platform, &mailbox, i);
if (block_size < CHASSIS_BOOT_MBOX_IANA_SZ && i == 0) {
/*
@@ -552,9 +553,12 @@ static int get_ipmi_boot_mailbox(struct platform_powerpc *platform,
if (i == 0) {
/*
* The first three bytes of block zero are an IANA
- * Enterprise ID number. Check it matches the IBM
- * number, '2'.
+ * Enterprise ID number
*/
+ block_size -= CHASSIS_BOOT_MBOX_IANA_SZ;
+ boot_opt_data = &mailbox.b0.data;
+
+ /* Check IANA matches the IBM number, '2' */
if (mailbox.b0.iana[0] != 0x02 ||
mailbox.b0.iana[1] != 0x00 ||
mailbox.b0.iana[2] != 0x00) {
@@ -564,6 +568,8 @@ static int get_ipmi_boot_mailbox(struct platform_powerpc *platform,
mailbox.b0.iana[2]);
return -1;
}
+ } else {
+ boot_opt_data = &mailbox.data;
}
mailbox_buffer = talloc_realloc(platform, mailbox_buffer,
@@ -572,7 +578,7 @@ static int get_ipmi_boot_mailbox(struct platform_powerpc *platform,
pb_log_fn("Failed to allocate mailbox buffer\n");
return -1;
}
- memcpy(mailbox_buffer + mailbox_size, &mailbox.data, block_size);
+ memcpy(mailbox_buffer + mailbox_size, boot_opt_data, block_size);
mailbox_size += block_size;
}
@@ -583,10 +589,10 @@ static int get_ipmi_boot_mailbox(struct platform_powerpc *platform,
else
pb_debug_fn("%hu blocks read (%zu bytes)\n", i, mailbox_size);
- if (mailbox_size < 3 + strlen("petitboot,bootdevs="))
+ if (mailbox_size < strlen("petitboot,bootdevs="))
return -1;
- prefix = talloc_strndup(mailbox_buffer, mailbox_buffer + 3,
+ prefix = talloc_strndup(mailbox_buffer, mailbox_buffer,
strlen("petitboot,bootdevs="));
if (!prefix) {
pb_log_fn("Couldn't check prefix\n");
@@ -604,9 +610,9 @@ static int get_ipmi_boot_mailbox(struct platform_powerpc *platform,
}
/* Don't include IANA number in buffer */
- content_size = mailbox_size - 3 - strlen("petitboot,bootdevs=");
+ content_size = mailbox_size - strlen("petitboot,bootdevs=");
*buf = talloc_memdup(platform,
- mailbox_buffer + 3 + strlen("petitboot,bootdevs="),
+ mailbox_buffer + strlen("petitboot,bootdevs="),
content_size + 1);
(*buf)[content_size] = '\0';
OpenPOWER on IntegriCloud