wifi: brcmfmac: zero-pad SDIO write buffer to 4-byte boundary
Subsystems (2)
PATCH v3 1/1 wifi: brcmfmac: zero-pad SDIO write buffer to 4-byte boundary
From: Tristan Madani <[email protected]>
brcmf_sdiod_skbuff_write() rounds skb->len up to the next 4-byte boundary and passes the larger size to sdio_memcpy_toio(). The 1-3 padding bytes beyond skb->data + skb->len are sent to the wireless device uninitialized.
The SDPCM header carries the original (unpadded) frame length, so the device discards the padding. The window is therefore limited to the local SDIO bus.
Ensure sufficient tailroom exists for the alignment padding before zeroing it. If the skb tailroom is too short, expand the head to make room.
---
Changes in v3:
- Check skb_tailroom() before zeroing the padding; if the skb tailroom is too short, call pskb_expand_head() to make room (Arend van Spriel)
- Use the correct Fixes tag: the 4-byte rounding was introduced by 78b3f1c5be8f, not by the later function split (Arend van Spriel)
- Add impact note: SDPCM header carries unpadded length, so device discards the extra bytes and the window is local SDIO bus only (Arend van Spriel)
Supersedes: f935e48bd9a6 ("wifi: brcmfmac: zero-pad SDIO write to 4-byte boundary")
Changes in v2:
- Original submission as part of [PATCH wireless 1/2] series
.../net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c +11 -0
@@ -317,12 +317,23 @@ static int brcmf_sdiod_skbuff_write(struct brcmf_sdio_dev *sdiodev, struct sk_buff *skb) {unsigned int req_sz; +unsigned int pad;int err;/* Single skb use the standard mmc interface */ req_sz = skb->len +3 ; req_sz &= (uint )~3 ; + pad = req_sz - skb->len; +if (pad >0 ) { +if (skb_tailroom (skb) < pad) { + err =pskb_expand_head (skb,0 , pad,GFP_ATOMIC ); +if (err) +return err; + } +memset (skb->data + skb->len,0 , pad); + } + err =sdio_memcpy_toio (func, addr, ((u8 *)(skb->data)), req_sz);if (err == -ENOMEDIUM )
Signature · 1 line
2.47.3