[PATCH 4/4] staging: octeon: fix IRQ leak error path and remove dst.h from ethernet-spi.c
From: Oscar Alejandro Sánchez Lucero via B4 Relay
Date: Sat Nov 07 2026 - 21:08:15 EST
From: Oscar Alejandro Sánchez Lucero <aleszlucero@xxxxxxxxx>
Fix a resource leak in cvm_oct_spi_init() by properly validating the
return value of cvm_oct_common_init(). If the common initialization
fails, perform a rollback by decrementing the spi port counter and
releasing the shared RML interrupt handler via free_irq().
Additionally, clean up the file header by removing the unused inclusion
of <net/dst.h>.
Signed-off-by: Oscar Alejandro Sánchez Lucero <aleszlucero@xxxxxxxxx>
---
drivers/staging/octeon/ethernet-spi.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/octeon/ethernet-spi.c b/drivers/staging/octeon/ethernet-spi.c
index 699c98c5ec13..e6ebc879ccad 100644
--- a/drivers/staging/octeon/ethernet-spi.c
+++ b/drivers/staging/octeon/ethernet-spi.c
@@ -8,7 +8,6 @@
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/interrupt.h>
-#include <net/dst.h>
#include "octeon-ethernet.h"
#include "ethernet-defines.h"
@@ -206,7 +205,14 @@ int cvm_oct_spi_init(struct net_device *dev)
cvm_oct_spi_enable_error_reporting(INTERFACE(priv->port));
priv->poll = cvm_oct_spi_poll;
}
- cvm_oct_common_init(dev);
+ r = cvm_oct_common_init(dev);
+ if (r) {
+ number_spi_ports--;
+ if (number_spi_ports == 0)
+ free_irq(OCTEON_IRQ_RML, &number_spi_ports);
+ return r;
+ }
+
return 0;
}
--
2.56.0