Skip to content

Commit

Permalink
mt76: round up length on mt76_wr_copy
Browse files Browse the repository at this point in the history
When beacon length is not a multiple of 4, the beacon could be sent with
the last 1-3 bytes corrupted. The skb data is guaranteed to have enough
room for reading beyond the end, because it is always followed by
skb_shared_info, so rounding up is safe.
All other callers of mt76_wr_copy have multiple-of-4 length already.

Cc: stable@vger.kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
  • Loading branch information
nbd168 committed Jul 1, 2019
1 parent 6cafaca commit 9e2e0b8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mmio.c
Expand Up @@ -43,7 +43,7 @@ static u32 mt76_mmio_rmw(struct mt76_dev *dev, u32 offset, u32 mask, u32 val)
static void mt76_mmio_copy(struct mt76_dev *dev, u32 offset, const void *data,
int len)
{
__iowrite32_copy(dev->mmio.regs + offset, data, len >> 2);
__iowrite32_copy(dev->mmio.regs + offset, data, DIV_ROUND_UP(len, 4));
}

static int mt76_mmio_wr_rp(struct mt76_dev *dev, u32 base,
Expand Down
2 changes: 1 addition & 1 deletion usb.c
Expand Up @@ -164,7 +164,7 @@ static void mt76u_copy(struct mt76_dev *dev, u32 offset,
int i, ret;

mutex_lock(&usb->usb_ctrl_mtx);
for (i = 0; i < (len / 4); i++) {
for (i = 0; i < DIV_ROUND_UP(len, 4); i++) {
put_unaligned_le32(val[i], usb->data);
ret = __mt76u_vendor_request(dev, MT_VEND_MULTI_WRITE,
USB_DIR_OUT | USB_TYPE_VENDOR,
Expand Down

0 comments on commit 9e2e0b8

Please sign in to comment.