Netdev List
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Scott Branden <scott.branden@broadcom.com>,
	Andrew Lunn <andrew@lunn.ch>,
	Abhishek Shah <abhishek.shah@broadcom.com>,
	Ray Jui <ray.jui@broadcom.com>,
	linux-kernel@vger.kernel.org (open list),
	jon.mason@broadcom.com, nbd@nbd.name
Subject: [PATCH net 2/2] net: bgmac: Fix endian access in bgmac_dma_tx_ring_free()
Date: Sun,  1 Apr 2018 10:26:30 -0700	[thread overview]
Message-ID: <20180401172630.12883-3-f.fainelli@gmail.com> (raw)
In-Reply-To: <20180401172630.12883-1-f.fainelli@gmail.com>

bgmac_dma_tx_ring_free() assigns the ctl1 word which is a litle endian
32-bit word without using proper accessors, fix this, and because a
length cannot be negative, use unsigned int while at it.

Fixes: 9cde94506eac ("bgmac: implement scatter/gather support")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/ethernet/broadcom/bgmac.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index 8eef9fb6b1fe..ad8195b0d161 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -533,7 +533,8 @@ static void bgmac_dma_tx_ring_free(struct bgmac *bgmac,
 	int i;
 
 	for (i = 0; i < BGMAC_TX_RING_SLOTS; i++) {
-		int len = dma_desc[i].ctl1 & BGMAC_DESC_CTL1_LEN;
+		u32 ctl1 = le32_to_cpu(dma_desc[i].ctl1);
+		unsigned int len = ctl1 & BGMAC_DESC_CTL1_LEN;
 
 		slot = &ring->slots[i];
 		dev_kfree_skb(slot->skb);
-- 
2.14.1

  parent reply	other threads:[~2018-04-01 17:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-01 17:26 [PATCH net 0/2] net: bgmac: Couple of sparse warnings Florian Fainelli
2018-04-01 17:26 ` [PATCH net 1/2] net: bgmac: Correctly annotate register space Florian Fainelli
2018-04-05  1:33   ` Sasha Levin
2018-04-01 17:26 ` Florian Fainelli [this message]
2018-04-05  1:33   ` [PATCH net 2/2] net: bgmac: Fix endian access in bgmac_dma_tx_ring_free() Sasha Levin
2018-04-02  2:21 ` [PATCH net 0/2] net: bgmac: Couple of sparse warnings David Miller
2018-04-02 17:17   ` Florian Fainelli
2018-04-02 17:18     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180401172630.12883-3-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=abhishek.shah@broadcom.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=jon.mason@broadcom.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=ray.jui@broadcom.com \
    --cc=scott.branden@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox