Skip to content

Commit b93a70b

Browse files
microchip1gregkh
authored andcommitted
net: ethernet: microchip: lan743x: Fix skb allocation failure
commit e8684db upstream. The driver allocates skb during ndo_open with GFP_ATOMIC which has high chance of failure when there are multiple instances. GFP_KERNEL is enough while open and use GFP_ATOMIC only from interrupt context. Fixes: 23f0703 ("lan743x: Add main source files for new lan743x driver") Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b9c85a7 commit b93a70b

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎drivers/net/ethernet/microchip/lan743x_main.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,13 +1963,13 @@ static int lan743x_rx_next_index(struct lan743x_rx *rx, int index)
19631963
return ((++index) % rx->ring_size);
19641964
}
19651965

1966-
static struct sk_buff *lan743x_rx_allocate_skb(struct lan743x_rx *rx)
1966+
static struct sk_buff *lan743x_rx_allocate_skb(struct lan743x_rx *rx, gfp_t gfp)
19671967
{
19681968
int length = 0;
19691969

19701970
length = (LAN743X_MAX_FRAME_SIZE + ETH_HLEN + 4 + RX_HEAD_PADDING);
19711971
return __netdev_alloc_skb(rx->adapter->netdev,
1972-
length, GFP_ATOMIC | GFP_DMA);
1972+
length, gfp);
19731973
}
19741974

19751975
static void lan743x_rx_update_tail(struct lan743x_rx *rx, int index)
@@ -2141,7 +2141,8 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx)
21412141
struct sk_buff *new_skb = NULL;
21422142
int packet_length;
21432143

2144-
new_skb = lan743x_rx_allocate_skb(rx);
2144+
new_skb = lan743x_rx_allocate_skb(rx,
2145+
GFP_ATOMIC | GFP_DMA);
21452146
if (!new_skb) {
21462147
/* failed to allocate next skb.
21472148
* Memory is very low.
@@ -2377,7 +2378,8 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx)
23772378

23782379
rx->last_head = 0;
23792380
for (index = 0; index < rx->ring_size; index++) {
2380-
struct sk_buff *new_skb = lan743x_rx_allocate_skb(rx);
2381+
struct sk_buff *new_skb = lan743x_rx_allocate_skb(rx,
2382+
GFP_KERNEL);
23812383

23822384
ret = lan743x_rx_init_ring_element(rx, index, new_skb);
23832385
if (ret)

0 commit comments

Comments
 (0)