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

Thomas Fourier posted 1 patch 1 day, 16 hours ago
drivers/net/can/sja1000/kvaser_pci.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH net] can: sja1000: Fix pci_iounmap() buffer
Posted by Thomas Fourier 1 day, 16 hours ago
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
Re: [PATCH net] can: sja1000: Fix pci_iounmap() buffer
Posted by Markus Elfring 23 hours ago
> 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().

Which action would indicate “cancelling” here?


Would it occasionally be preferred to specify selected message recipients
also in the header “To”?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.0-rc6#n231

Regards,
Markus