mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] staging: octeon: cleanups and error handling fixes in ethernet-rx.c
@ 2026-11-07 11:06 Oscar Alejandro Sánchez Lucero via B4 Relay
  2026-11-07 11:06 ` [PATCH 1/2] staging: octeon: avoid void pointer arithmetic " Oscar Alejandro Sánchez Lucero via B4 Relay
  2026-11-07 11:06 ` [PATCH 2/2] staging: octeon: fix error handling rollback in cvm_oct_rx_initialize() Oscar Alejandro Sánchez Lucero via B4 Relay
  0 siblings, 2 replies; 3+ messages in thread
From: Oscar Alejandro Sánchez Lucero via B4 Relay @ 2026-11-07 11:06 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-staging, linux-kernel, Oscar Alejandro Sánchez Lucero

This series fixes a couple of issues found during code review and static
analysis of drivers/staging/octeon/ethernet-rx.c:

1. Avoid non-standard GCC pointer arithmetic on void * in cvm_oct_poll()
   by casting to u8 * first.
2. Add a proper error rollback path in cvm_oct_rx_initialize() so that
   NAPI instances, interrupts, and POW/SSO registers from previous loop
   iterations are properly cleaned up if request_irq() fails.

Signed-off-by: Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>
---
Oscar Alejandro Sánchez Lucero (2):
      staging: octeon: avoid void pointer arithmetic in ethernet-rx.c
      staging: octeon: fix error handling rollback in cvm_oct_rx_initialize()

 drivers/staging/octeon/ethernet-rx.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
---
base-commit: ddfe51b0a0f5dc9e415cc2c8ad8db17532dd426b
change-id: 20261107-octeon-rx-fixes-d4d7620258c9

Best regards,
-- 
Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>



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

* [PATCH 1/2] staging: octeon: avoid void pointer arithmetic in ethernet-rx.c
  2026-11-07 11:06 [PATCH 0/2] staging: octeon: cleanups and error handling fixes in ethernet-rx.c Oscar Alejandro Sánchez Lucero via B4 Relay
@ 2026-11-07 11:06 ` Oscar Alejandro Sánchez Lucero via B4 Relay
  2026-11-07 11:06 ` [PATCH 2/2] staging: octeon: fix error handling rollback in cvm_oct_rx_initialize() Oscar Alejandro Sánchez Lucero via B4 Relay
  1 sibling, 0 replies; 3+ messages in thread
From: Oscar Alejandro Sánchez Lucero via B4 Relay @ 2026-11-07 11:06 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-staging, linux-kernel, Oscar Alejandro Sánchez Lucero

From: Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>

Arithmetic on void pointers is a non-standard GCC extension and
triggers -Wpointer-arith warnings. Cast the buffer pointer
returned by cvm_oct_get_buffer_ptr() to u8 * before subtracting
the offset.

Signed-off-by: Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>
---
 drivers/staging/octeon/ethernet-rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
index 5be43bbf6a1d..b0463759be39 100644
--- a/drivers/staging/octeon/ethernet-rx.c
+++ b/drivers/staging/octeon/ethernet-rx.c
@@ -243,7 +243,7 @@ static int cvm_oct_poll(struct oct_rx_group *rx_group, int budget)
 			break;
 		}
 		pskb = (struct sk_buff **)
-			(cvm_oct_get_buffer_ptr(work->packet_ptr) -
+			((u8 *)cvm_oct_get_buffer_ptr(work->packet_ptr) -
 			sizeof(void *));
 		prefetch(pskb);
 

-- 
2.56.0



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

* [PATCH 2/2] staging: octeon: fix error handling rollback in cvm_oct_rx_initialize()
  2026-11-07 11:06 [PATCH 0/2] staging: octeon: cleanups and error handling fixes in ethernet-rx.c Oscar Alejandro Sánchez Lucero via B4 Relay
  2026-11-07 11:06 ` [PATCH 1/2] staging: octeon: avoid void pointer arithmetic " Oscar Alejandro Sánchez Lucero via B4 Relay
@ 2026-11-07 11:06 ` Oscar Alejandro Sánchez Lucero via B4 Relay
  1 sibling, 0 replies; 3+ messages in thread
From: Oscar Alejandro Sánchez Lucero via B4 Relay @ 2026-11-07 11:06 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-staging, linux-kernel, Oscar Alejandro Sánchez Lucero

From: Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>

If request_irq() fails during the loop in cvm_oct_rx_initialize(),
the function returns immediately without disabling and deleting the
current NAPI context or cleaning up the previously initialized RX
groups.

Add an error unwind path to disable/delete the failed NAPI instance
and tear down all previously registered RX groups in reverse order.

Signed-off-by: Oscar Alejandro Sánchez Lucero <aleszlucero@gmail.com>
---
 drivers/staging/octeon/ethernet-rx.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
index b0463759be39..61593283ddef 100644
--- a/drivers/staging/octeon/ethernet-rx.c
+++ b/drivers/staging/octeon/ethernet-rx.c
@@ -449,7 +449,7 @@ void cvm_oct_poll_controller(struct net_device *dev)
 
 int cvm_oct_rx_initialize(struct platform_device *pdev)
 {
-	int i;
+	int i, ret;
 	struct net_device *dev_for_napi = NULL;
 	struct octeon_ethernet_platform *plat = platform_get_drvdata(pdev);
 	struct oct_rx_group *rx_group = plat->rx_group;
@@ -467,8 +467,6 @@ int cvm_oct_rx_initialize(struct platform_device *pdev)
 	}
 
 	for (i = 0; i < ARRAY_SIZE(plat->rx_group); i++) {
-		int ret;
-
 		if (!(pow_receive_groups & BIT(i)))
 			continue;
 
@@ -485,7 +483,9 @@ int cvm_oct_rx_initialize(struct platform_device *pdev)
 				  "Ethernet", &rx_group[i].napi);
 		if (ret) {
 			dev_err(&pdev->dev, "Could not acquire Ethernet IRQ %d\n", rx_group[i].irq);
-			return ret;
+			napi_disable(&rx_group[i].napi);
+			netif_napi_del(&rx_group[i].napi);
+			goto err_rollback;
 		}
 
 		disable_irq_nosync(rx_group[i].irq);
@@ -524,6 +524,22 @@ int cvm_oct_rx_initialize(struct platform_device *pdev)
 	}
 	atomic_inc(&oct_rx_ready);
 	return 0;
+
+err_rollback:
+	while (--i >= 0) {
+		if (!(pow_receive_groups & BIT(i)))
+			continue;
+
+		if (OCTEON_IS_MODEL(OCTEON_CN68XX))
+			cvmx_write_csr(CVMX_SSO_WQ_INT_THRX(i), 0);
+		else
+			cvmx_write_csr(CVMX_POW_WQ_INT_THRX(i), 0);
+
+		napi_disable(&rx_group[i].napi);
+		free_irq(rx_group[i].irq, &rx_group[i].napi);
+		netif_napi_del(&rx_group[i].napi);
+	}
+	return ret;
 }
 
 void cvm_oct_rx_shutdown(struct platform_device *pdev)

-- 
2.56.0



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

end of thread, other threads:[~2026-11-07 11:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-07 11:06 [PATCH 0/2] staging: octeon: cleanups and error handling fixes in ethernet-rx.c Oscar Alejandro Sánchez Lucero via B4 Relay
2026-11-07 11:06 ` [PATCH 1/2] staging: octeon: avoid void pointer arithmetic " Oscar Alejandro Sánchez Lucero via B4 Relay
2026-11-07 11:06 ` [PATCH 2/2] staging: octeon: fix error handling rollback in cvm_oct_rx_initialize() Oscar Alejandro Sánchez Lucero via B4 Relay

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®