Skip to contentSkip to conversation

net:fec:Fix error checking in the function fec_enet_init

PATCH RESEND Fugang Duan 2 participants 3 messages Mar 6, 2016 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Fugang Duan

author Acked-by
#1 lore raw

From: Nicholas Krause <[email protected]> Sent: Saturday, March 05, 2016 4:00 AM

Quoted 42 lines

To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH RESEND] net:fec:Fix error checking in the function fec_enet_init

This fixes error checking in the function fec_enet_init to properly check if the internal call to the function fec_enet_alloc_queue fails and if so immediately return the error code to the caller for it to handle it's own intended error paths.

---
 drivers/net/ethernet/freescale/fec_main.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/fec_main.c +4 -2
index b349e6f..18c625f 100644
@@ -3123,6 +3123,7 @@ static int fec_enet_init(struct net_device *ndev)
 	dma_addr_t bd_dma;
 	int bd_size;
 	unsigned int i;
+	int ret;
 
 #if defined(CONFIG_ARM)
 	fep->rx_align = 0xf;
@@ -3132,7 +3133,9 @@ static int fec_enet_init(struct net_device *ndev)
 	fep->tx_align = 0x3;
 #endif
 
-	fec_enet_alloc_queue(ndev);
+	ret = fec_enet_alloc_queue(ndev);
+	if (ret)
+		return ret;
 
 	if (fep->bufdesc_ex)
 		fep->bufdesc_size = sizeof(struct bufdesc_ex);
--
Quoted 1 line

2.1.4

Thanks.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

From: nick <[email protected]> Sent: Sunday, March 06, 2016 11:50 AM

Quoted 61 lines

To: Fugang Duan <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH RESEND] net:fec:Fix error checking in the function fec_enet_init

Quoted 15 lines · Fugang Duan

From: Nicholas Krause <[email protected]> Sent: Saturday, March 05, 2016 4:00 AM

Quoted 13 lines

To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH RESEND] net:fec:Fix error checking in the function fec_enet_init

This fixes error checking in the function fec_enet_init to properly check if the internal call to the function fec_enet_alloc_queue fails and if so immediately return the error code to the caller for it to handle it's

own intended error paths.

Quoted 34 lines
Quoted 31 lines
---
 drivers/net/ethernet/freescale/fec_main.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/fec_main.c +4 -2
index b349e6f..18c625f 100644
@@ -3123,6 +3123,7 @@ static int fec_enet_init(struct net_device *ndev)
 	dma_addr_t bd_dma;
 	int bd_size;
 	unsigned int i;
+	int ret;
 
 #if defined(CONFIG_ARM)
 	fep->rx_align = 0xf;
@@ -3132,7 +3133,9 @@ static int fec_enet_init(struct net_device *ndev)
 	fep->tx_align = 0x3;
 #endif
 
-	fec_enet_alloc_queue(ndev);
+	ret = fec_enet_alloc_queue(ndev);
+	if (ret)
+		return ret;
 
 	if (fep->bufdesc_ex)
 		fep->bufdesc_size = sizeof(struct bufdesc_ex);
--
Quoted 1 line

2.1.4

Thanks.

Quoted 7 lines
Quoted 2 lines

Fugang,
I have a few other patches for freescale ethernet drivers lying around. Would you like me to resend them or are you just taking this one patch? Cheers,
Nick

Hi Nick,

Pls resend them, thanks.

Regards,
Andy

#4 lore raw
In reply to a message not in the archive

Hello Nicholas,

Quoted 6 lines · Nicholas Krause

This fixes error checking in the function fec_enet_init to properly check if the internal call to the function fec_enet_alloc_queue fails and if so immediately return the error code to the caller for it to handle it's own intended error paths.

Looks right. There seem to be some more oportunities for similar patches. E.g. if dmam_alloc_coherent fails the effects of fec_enet_alloc_queue should be undone.

Best regards
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |