[PATCH net] can: sja1000: Fix pci_iounmap() buffer

Thomas Fourier
2026-03-30T15:43:29Z

The base_addr is mapped in kvaser_pci_init_one() and the pointer is
copied to priv->reg_base in kvaser_pci_add_chan() with offset
channel * KVASER_PCI_PORT_BYTES but unmapped without the offset.

Cancel the offset before calling pci_iounmap().

Fixes: 255a9154319d ("can: sja1000: stop misusing member base_addr of struct net_device")
Cc: <stable@vger.kernel.org>
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
drivers/net/can/sja1000/kvaser_pci.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/can/sja1000/kvaser_pci.c b/drivers/net/can/sja1000/kvaser_pci.c
index 95fe9ee1ce32..213fd0eb07e7 100644
--- a/drivers/net/can/sja1000/kvaser_pci.c
+++ b/drivers/net/can/sja1000/kvaser_pci.c
@@ -161,6 +161,7 @@ static void kvaser_pci_del_chan(struct net_device *dev)
{
struct sja1000_priv *priv;
struct kvaser_pci *board;
+ void __iomem *base_addr;
int i;

if (!dev)
@@ -186,7 +187,8 @@ static void kvaser_pci_del_chan(struct net_device *dev)
}
unregister_sja1000dev(dev);

- pci_iounmap(board->pci_dev, priv->reg_base);
+ base_addr = priv->reg_base - board->channel * KVASER_PCI_PORT_BYTES;
+ pci_iounmap(board->pci_dev, base_addr);
pci_iounmap(board->pci_dev, board->conf_addr);
pci_iounmap(board->pci_dev, board->res_addr);

--
2.43.0