aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2009-03-27 00:50:53 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-04-22 16:54:27 -0400
commit9f201a87831af9458df1eda65941c955f2da87ed (patch)
tree6203d7556d501769d2bd551afe25233a4b98cf6c
parent488829f1b141858944a24fd793220fa1d52cd9a6 (diff)
p54spi: compensate firmware alignment bug in p54spi_rx
Firmware may insert up to 4 padding bytes after the lmac header, but it does not amend the size of SPI data transfer. Such packets has correct data size in header, thus referencing past the end of allocated skb. Put extra 4 bytes to the end of the received skb to compensate for this case. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Acked-by: Christian Lamparter <chunkeey@web.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/p54/p54spi.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/net/wireless/p54/p54spi.c b/drivers/net/wireless/p54/p54spi.c
index f8af0961018..52023127cf3 100644
--- a/drivers/net/wireless/p54/p54spi.c
+++ b/drivers/net/wireless/p54/p54spi.c
@@ -395,7 +395,12 @@ static int p54spi_rx(struct p54s_priv *priv)
395 return 0; 395 return 0;
396 } 396 }
397 397
398 skb = dev_alloc_skb(len); 398
399 /* Firmware may insert up to 4 padding bytes after the lmac header,
400 * but it does not amend the size of SPI data transfer.
401 * Such packets has correct data size in header, thus referencing
402 * past the end of allocated skb. Reserve extra 4 bytes for this case */
403 skb = dev_alloc_skb(len + 4);
399 if (!skb) { 404 if (!skb) {
400 dev_err(&priv->spi->dev, "could not alloc skb"); 405 dev_err(&priv->spi->dev, "could not alloc skb");
401 return 0; 406 return 0;
@@ -403,6 +408,9 @@ static int p54spi_rx(struct p54s_priv *priv)
403 408
404 p54spi_spi_read(priv, SPI_ADRS_DMA_DATA, skb_put(skb, len), len); 409 p54spi_spi_read(priv, SPI_ADRS_DMA_DATA, skb_put(skb, len), len);
405 p54spi_sleep(priv); 410 p54spi_sleep(priv);
411 /* Put additional bytes to compensate for the possible
412 * alignment-caused truncation */
413 skb_put(skb, 4);
406 414
407 if (p54_rx(priv->hw, skb) == 0) 415 if (p54_rx(priv->hw, skb) == 0)
408 dev_kfree_skb(skb); 416 dev_kfree_skb(skb);