Skip to content

Commit

Permalink
hdata/iohub: fix load of misaligned address for type 'long unsigned i…
Browse files Browse the repository at this point in the history
…nt', which requires 8 byte alignment

UBSan caught this:

hdata/test/../iohub.c:83:2: runtime error: load of misaligned address 0x7f1dc7b0210a for type 'long unsigned int', which requires 8 byte alignment
0x7f1dc7b0210a: note: pointer points here
 31 4c  58 08 31 00 04 01 00 30  00 42 50 46 02 00 00 78  00 00 00 00 00 00 00 00  00 00 00 00 00 00
              ^
    #0 0x41470a in io_get_lx_info hdata/test/../iohub.c:83
    open-power#1 0x41759f in io_add_p8_cec_vpd hdata/test/../iohub.c:450
    open-power#2 0x417d35 in io_parse_fru hdata/test/../iohub.c:538
    open-power#3 0x41812a in io_parse hdata/test/../iohub.c:600
    open-power#4 0x425aa2 in parse_hdat hdata/test/../spira.c:1337
    open-power#5 0x43d9f8 in main hdata/test/hdata_to_dt.c:358
    open-power#6 0x7f1dcb868509 in __libc_start_main (/lib64/libc.so.6+0x20509)
    open-power#7 0x4019e9 in _start (/home/stewart/skiboot/hdata/test/hdata_to_dt+0x4019e9)

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
  • Loading branch information
stewartsmith committed Aug 23, 2017
1 parent 192d426 commit a953475
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions hdata/iohub.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ static bool io_get_lx_info(const void *kwvpd, unsigned int kwvpd_sz,
{
const void *lxr;
char recname[5];
uint32_t lxrbuf[2] = { 0, 0 };

/* Find LXRn, where n is the index passed in*/
strcpy(recname, "LXR0");
Expand All @@ -80,16 +81,18 @@ static bool io_get_lx_info(const void *kwvpd, unsigned int kwvpd_sz,
return false;
}

prlog(PR_DEBUG, "CEC: LXRn=%d LXR=%016lx\n", lx_idx,
lxr ? *(unsigned long *)lxr : 0);
if (lxr)
memcpy(lxrbuf, lxr, sizeof(uint32_t)*2);

prlog(PR_DEBUG, "CEC: LXRn=%d LXR=%08x%08x\n", lx_idx, lxrbuf[0], lxrbuf[1]);
prlog(PR_DEBUG, "CEC: LX Info added to %llx\n", (long long)hn);

/* Add the LX info */
if (!dt_has_node_property(hn, "ibm,vpd-lx-info", NULL)) {
dt_add_property_cells(hn, "ibm,vpd-lx-info",
lx_idx,
((uint32_t *)lxr)[0],
((uint32_t *)lxr)[1]);
lxrbuf[0],
lxrbuf[1]);
}

return true;
Expand Down

0 comments on commit a953475

Please sign in to comment.