* [PATCH] ftgmac100: return error in ftgmac100_alloc_rx_buf
@ 2017-07-25 0:49 Joel Stanley
2017-07-26 4:22 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Joel Stanley @ 2017-07-25 0:49 UTC (permalink / raw)
To: David S . Miller; +Cc: Benjamin Herrenschmidt, netdev
The error paths set err, but it's not returned.
I wondered if we should fix all of the callers to check the returned
value, but Ben explains why the code is this way:
> Most call sites ignore it on purpose. There's nothing we can do if
> we fail to get a buffer at interrupt time, so we point the buffer to
> the scratch page so the HW doesn't DMA into lalaland and lose the
> packet.
>
> The one call site that tests and can fail is the one used when brining
> the interface up. If we fail to allocate at that point, we fail the
> ifup. But as you noticed, I do have a bug not returning the error.
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Joel Stanley <joel@jms.id.au>
---
drivers/net/ethernet/faraday/ftgmac100.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
index fce0aa4f78b7..33b5c8eb9961 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -392,7 +392,7 @@ static int ftgmac100_alloc_rx_buf(struct ftgmac100 *priv, unsigned int entry,
struct net_device *netdev = priv->netdev;
struct sk_buff *skb;
dma_addr_t map;
- int err;
+ int err = 0;
skb = netdev_alloc_skb_ip_align(netdev, RX_BUF_SIZE);
if (unlikely(!skb)) {
@@ -428,7 +428,7 @@ static int ftgmac100_alloc_rx_buf(struct ftgmac100 *priv, unsigned int entry,
else
rxdes->rxdes0 = 0;
- return 0;
+ return err;
}
static unsigned int ftgmac100_next_rx_pointer(struct ftgmac100 *priv,
--
2.13.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ftgmac100: return error in ftgmac100_alloc_rx_buf
2017-07-25 0:49 [PATCH] ftgmac100: return error in ftgmac100_alloc_rx_buf Joel Stanley
@ 2017-07-26 4:22 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-07-26 4:22 UTC (permalink / raw)
To: joel; +Cc: benh, netdev
From: Joel Stanley <joel@jms.id.au>
Date: Tue, 25 Jul 2017 10:19:01 +0930
> The error paths set err, but it's not returned.
>
> I wondered if we should fix all of the callers to check the returned
> value, but Ben explains why the code is this way:
>
>> Most call sites ignore it on purpose. There's nothing we can do if
>> we fail to get a buffer at interrupt time, so we point the buffer to
>> the scratch page so the HW doesn't DMA into lalaland and lose the
>> packet.
>>
>> The one call site that tests and can fail is the one used when brining
>> the interface up. If we fail to allocate at that point, we fail the
>> ifup. But as you noticed, I do have a bug not returning the error.
>
> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-26 4:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-25 0:49 [PATCH] ftgmac100: return error in ftgmac100_alloc_rx_buf Joel Stanley
2017-07-26 4:22 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox