stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: ethernet: microchip: lan743x: Fix skb allocation failure
@ 2021-11-02 14:10 Yuiko Oshino
  0 siblings, 0 replies; 4+ messages in thread
From: Yuiko Oshino @ 2021-11-02 14:10 UTC (permalink / raw)
  To: yuiko.oshino; +Cc: stable

commit e8684db191e4164f3f5f3ad7dec04a6734c25f1c 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: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
cc: <stable@vger.kernel.org> # 5.4.x
---
 drivers/net/ethernet/microchip/lan743x_main.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index dfa0ded169ee..d335fad34dd3 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -1888,13 +1888,13 @@ static int lan743x_rx_next_index(struct lan743x_rx *rx, int index)
 	return ((++index) % rx->ring_size);
 }
 
-static struct sk_buff *lan743x_rx_allocate_skb(struct lan743x_rx *rx)
+static struct sk_buff *lan743x_rx_allocate_skb(struct lan743x_rx *rx, gfp_t gfp)
 {
 	int length = 0;
 
 	length = (LAN743X_MAX_FRAME_SIZE + ETH_HLEN + 4 + RX_HEAD_PADDING);
 	return __netdev_alloc_skb(rx->adapter->netdev,
-				  length, GFP_ATOMIC | GFP_DMA);
+				  length, gfp);
 }
 
 static void lan743x_rx_update_tail(struct lan743x_rx *rx, int index)
@@ -2067,7 +2067,8 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx)
 			struct sk_buff *new_skb = NULL;
 			int packet_length;
 
-			new_skb = lan743x_rx_allocate_skb(rx);
+			new_skb = lan743x_rx_allocate_skb(rx,
+							  GFP_ATOMIC | GFP_DMA);
 			if (!new_skb) {
 				/* failed to allocate next skb.
 				 * Memory is very low.
@@ -2294,7 +2295,8 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx)
 
 	rx->last_head = 0;
 	for (index = 0; index < rx->ring_size; index++) {
-		struct sk_buff *new_skb = lan743x_rx_allocate_skb(rx);
+		struct sk_buff *new_skb = lan743x_rx_allocate_skb(rx,
+								   GFP_KERNEL);
 
 		ret = lan743x_rx_init_ring_element(rx, index, new_skb);
 		if (ret)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH net] net: ethernet: microchip: lan743x: Fix skb allocation failure
  2021-11-03  9:43 ` Greg KH
@ 2021-11-03 11:28   ` Yuiko.Oshino
  0 siblings, 0 replies; 4+ messages in thread
From: Yuiko.Oshino @ 2021-11-03 11:28 UTC (permalink / raw)
  To: greg; +Cc: stable

>-----Original Message-----
>From: Greg KH <greg@kroah.com>
>Sent: Wednesday, November 3, 2021 5:44 AM
>To: Yuiko Oshino - C18177 <Yuiko.Oshino@microchip.com>
>Cc: stable@vger.kernel.org
>Subject: Re: [PATCH net] net: ethernet: microchip: lan743x: Fix skb allocation
>failure
>
>[You don't often get email from greg@kroah.com. Learn why this is important at
>http://aka.ms/LearnAboutSenderIdentification.]
>
>EXTERNAL EMAIL: Do not click links or open attachments unless you know the
>content is safe
>
>On Tue, Nov 02, 2021 at 10:14:27AM -0400, Yuiko Oshino wrote:
>> commit e8684db191e4164f3f5f3ad7dec04a6734c25f1c 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: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
>> Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
>> cc: <stable@vger.kernel.org> # 5.4.x
>
>Now queued up, thanks.
>
>greg k-h

Thank you, Greg!

Yuiko

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: ethernet: microchip: lan743x: Fix skb allocation failure
  2021-11-02 14:14 Yuiko Oshino
@ 2021-11-03  9:43 ` Greg KH
  2021-11-03 11:28   ` Yuiko.Oshino
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2021-11-03  9:43 UTC (permalink / raw)
  To: Yuiko Oshino; +Cc: stable

On Tue, Nov 02, 2021 at 10:14:27AM -0400, Yuiko Oshino wrote:
> commit e8684db191e4164f3f5f3ad7dec04a6734c25f1c 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: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
> Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
> cc: <stable@vger.kernel.org> # 5.4.x

Now queued up, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net] net: ethernet: microchip: lan743x: Fix skb allocation failure
@ 2021-11-02 14:14 Yuiko Oshino
  2021-11-03  9:43 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Yuiko Oshino @ 2021-11-02 14:14 UTC (permalink / raw)
  To: stable; +Cc: Yuiko Oshino

commit e8684db191e4164f3f5f3ad7dec04a6734c25f1c 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: 23f0703c125b ("lan743x: Add main source files for new lan743x driver")
Signed-off-by: Yuiko Oshino <yuiko.oshino@microchip.com>
cc: <stable@vger.kernel.org> # 5.4.x
---
 drivers/net/ethernet/microchip/lan743x_main.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
index dfa0ded169ee..d335fad34dd3 100644
--- a/drivers/net/ethernet/microchip/lan743x_main.c
+++ b/drivers/net/ethernet/microchip/lan743x_main.c
@@ -1888,13 +1888,13 @@ static int lan743x_rx_next_index(struct lan743x_rx *rx, int index)
 	return ((++index) % rx->ring_size);
 }
 
-static struct sk_buff *lan743x_rx_allocate_skb(struct lan743x_rx *rx)
+static struct sk_buff *lan743x_rx_allocate_skb(struct lan743x_rx *rx, gfp_t gfp)
 {
 	int length = 0;
 
 	length = (LAN743X_MAX_FRAME_SIZE + ETH_HLEN + 4 + RX_HEAD_PADDING);
 	return __netdev_alloc_skb(rx->adapter->netdev,
-				  length, GFP_ATOMIC | GFP_DMA);
+				  length, gfp);
 }
 
 static void lan743x_rx_update_tail(struct lan743x_rx *rx, int index)
@@ -2067,7 +2067,8 @@ static int lan743x_rx_process_packet(struct lan743x_rx *rx)
 			struct sk_buff *new_skb = NULL;
 			int packet_length;
 
-			new_skb = lan743x_rx_allocate_skb(rx);
+			new_skb = lan743x_rx_allocate_skb(rx,
+							  GFP_ATOMIC | GFP_DMA);
 			if (!new_skb) {
 				/* failed to allocate next skb.
 				 * Memory is very low.
@@ -2294,7 +2295,8 @@ static int lan743x_rx_ring_init(struct lan743x_rx *rx)
 
 	rx->last_head = 0;
 	for (index = 0; index < rx->ring_size; index++) {
-		struct sk_buff *new_skb = lan743x_rx_allocate_skb(rx);
+		struct sk_buff *new_skb = lan743x_rx_allocate_skb(rx,
+								   GFP_KERNEL);
 
 		ret = lan743x_rx_init_ring_element(rx, index, new_skb);
 		if (ret)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-03 11:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02 14:10 [PATCH net] net: ethernet: microchip: lan743x: Fix skb allocation failure Yuiko Oshino
2021-11-02 14:14 Yuiko Oshino
2021-11-03  9:43 ` Greg KH
2021-11-03 11:28   ` Yuiko.Oshino

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).