Skip to content

Commit a921486

Browse files
alvin0603gregkh
authored andcommitted
staging: vme_user: fix location monitor leak in fake bridge
commit e8422d8 upstream. fake_init() allocates a location monitor resource and links it into fake_bridge->lm_resources. The init error path frees this list, but fake_exit() only frees the slave and master resource lists. Loading and unloading the module therefore triggers a kmemleak warning: unreferenced object 0xffff8b8b82aebe40 (size 64): comm "init", pid 1, jiffies 4294894572 backtrace (crc c1e013ef): kmemleak_alloc+0x4e/0x90 __kmalloc_cache_noprof+0x338/0x430 0xffffffffc0602246 do_one_initcall+0x4f/0x320 do_init_module+0x68/0x270 load_module+0x2a3b/0x2d90 Free the lm_resources list in fake_exit() as well, before fake_bridge is freed. Fixes: 658bcda ("vme: Adding Fake VME 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-1-alvinhuang0603@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ceb875a commit a921486

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

drivers/staging/vme_user/vme_fake.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,7 @@ static void __exit fake_exit(void)
12391239
{
12401240
struct list_head *pos = NULL;
12411241
struct list_head *tmplist;
1242+
struct vme_lm_resource *lm;
12421243
struct vme_master_resource *master_image;
12431244
struct vme_slave_resource *slave_image;
12441245
int i;
@@ -1268,6 +1269,13 @@ static void __exit fake_exit(void)
12681269
vme_unregister_bridge(fake_bridge);
12691270

12701271
fake_crcsr_exit(fake_bridge);
1272+
/* resources are stored in link list */
1273+
list_for_each_safe(pos, tmplist, &fake_bridge->lm_resources) {
1274+
lm = list_entry(pos, struct vme_lm_resource, list);
1275+
list_del(pos);
1276+
kfree(lm);
1277+
}
1278+
12711279
/* resources are stored in link list */
12721280
list_for_each_safe(pos, tmplist, &fake_bridge->slave_resources) {
12731281
slave_image = list_entry(pos, struct vme_slave_resource, list);

0 commit comments

Comments
 (0)