Skip to content

Commit 9272e5d

Browse files
Yunlongsgregkh
authored andcommitted
ipack/carriers/tpci200: Fix a double free in tpci200_pci_probe
In the out_err_bus_register error branch of tpci200_pci_probe, tpci200->info->cfg_regs is freed by tpci200_uninstall()-> tpci200_unregister()->pci_iounmap(..,tpci200->info->cfg_regs) in the first time. But later, iounmap() is called to free tpci200->info->cfg_regs again. My patch sets tpci200->info->cfg_regs to NULL after tpci200_uninstall() to avoid the double free. Fixes: cea2f7c ("Staging: ipack/bridges/tpci200: Use the TPCI200 in big endian mode") Cc: stable <[email protected]> Acked-by: Samuel Iglesias Gonsalvez <[email protected]> Signed-off-by: Lv Yunlong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent a53d120 commit 9272e5d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/ipack/carriers/tpci200.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,11 @@ static int tpci200_pci_probe(struct pci_dev *pdev,
596596

597597
out_err_bus_register:
598598
tpci200_uninstall(tpci200);
599+
/* tpci200->info->cfg_regs is unmapped in tpci200_uninstall */
600+
tpci200->info->cfg_regs = NULL;
599601
out_err_install:
600-
iounmap(tpci200->info->cfg_regs);
602+
if (tpci200->info->cfg_regs)
603+
iounmap(tpci200->info->cfg_regs);
601604
out_err_ioremap:
602605
pci_release_region(pdev, TPCI200_CFG_MEM_BAR);
603606
out_err_pci_request:

0 commit comments

Comments
 (0)