diff --git a/drivers/mailbox/ti-msgmgr.c b/drivers/mailbox/ti-msgmgr.c index 52136f99f54f..2079996092f5 100644 --- a/drivers/mailbox/ti-msgmgr.c +++ b/drivers/mailbox/ti-msgmgr.c @@ -20,6 +20,7 @@ #include #include #include +#include #define Q_DATA_OFFSET(proxy, queue, reg) \ ((0x10000 * (proxy)) + (0x80 * (queue)) + ((reg) * 4)) @@ -425,10 +426,15 @@ static int ti_msgmgr_send_data(struct mbox_chan *chan, void *data) trail_bytes = message->len % sizeof(u32); if (trail_bytes) { - u32 data_trail = *word_data; + /* + * Copy only the trailing bytes instead of reading a full u32, + * as the message buffer may end right after them and a u32 + * read would go past the end of it. This also leaves all + * unused data as 0. + */ + u32 data_trail = 0; - /* Ensure all unused data is 0 */ - data_trail &= 0xFFFFFFFF >> (8 * (sizeof(u32) - trail_bytes)); + memcpy(&data_trail, word_data, trail_bytes); writel(data_trail, data_reg); data_reg += sizeof(u32); }