Skip to content

Commit e3ceafa

Browse files
alvin0603gregkh
authored andcommitted
staging: vme_user: fix location monitor leak in tsi148 bridge
commit 151edde upstream. tsi148_probe() allocates a location monitor resource and links it into tsi148_bridge->lm_resources. The probe error path frees this list, but tsi148_remove() only frees the dma, slave and master resource lists, so the location monitor resource is leaked on device unbind or module unload. Free the lm_resources list in tsi148_remove() as well, before tsi148_bridge is freed. Fixes: d22b8ed ("Staging: vme: add Tundra TSI148 VME-PCI Bridge driver") Cc: stable <stable@kernel.org> Cc: Martyn Welch <martyn@welchs.me.uk> Assisted-by: Claude:claude-fable-5 Signed-off-by: Hao-Qun Huang <alvinhuang0603@gmail.com> Link: https://patch.msgid.link/20260704065817.403111-2-alvinhuang0603@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a921486 commit e3ceafa

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/staging/vme_user/vme_tsi148.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2536,6 +2536,7 @@ static void tsi148_remove(struct pci_dev *pdev)
25362536
{
25372537
struct list_head *pos = NULL;
25382538
struct list_head *tmplist;
2539+
struct vme_lm_resource *lm;
25392540
struct vme_master_resource *master_image;
25402541
struct vme_slave_resource *slave_image;
25412542
struct vme_dma_resource *dma_ctrlr;
@@ -2592,6 +2593,13 @@ static void tsi148_remove(struct pci_dev *pdev)
25922593

25932594
tsi148_crcsr_exit(tsi148_bridge, pdev);
25942595

2596+
/* resources are stored in link list */
2597+
list_for_each_safe(pos, tmplist, &tsi148_bridge->lm_resources) {
2598+
lm = list_entry(pos, struct vme_lm_resource, list);
2599+
list_del(pos);
2600+
kfree(lm);
2601+
}
2602+
25952603
/* resources are stored in link list */
25962604
list_for_each_safe(pos, tmplist, &tsi148_bridge->dma_resources) {
25972605
dma_ctrlr = list_entry(pos, struct vme_dma_resource, list);

0 commit comments

Comments
 (0)