lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200617163900.17674-1-pierre-louis.bossart@linux.intel.com>
Date:   Wed, 17 Jun 2020 11:39:00 -0500
From:   Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
To:     alsa-devel@...a-project.org
Cc:     tiwai@...e.de, broonie@...nel.org, vkoul@...nel.org,
        gregkh@...uxfoundation.org,
        Bard liao <yung-chuan.liao@...ux.intel.com>,
        Rander Wang <rander.wang@...ux.intel.com>,
        linux-kernel@...r.kernel.org,
        Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>,
        Daniel Baluta <daniel.baluta@...il.com>,
        Kai Vehmanen <kai.vehmanen@...ux.intel.com>,
        Guennadi Liakhovetski <guennadi.liakhovetski@...ux.intel.com>
Subject: [PATCH] regmap: fix memory leak with map->patch

kmemleak throws the following error on devices using
regmap_register_patch().  map->patch is allocated dynamically with
krealloc() but never freed.

root@...ac:~/kmod# cat /sys/kernel/debug/kmemleak
unreferenced object 0xffff8880641c4e08 (size 96):
  comm "systemd-udevd", pid 266, jiffies 4294736541 (age 414.914s)
  hex dump (first 32 bytes):
    3d 01 00 00 00 36 00 00 00 00 00 00 12 01 00 00  =....6..........
    a8 0a 00 00 00 00 00 00 14 01 00 00 aa 0a 00 00  ................
  backtrace:
    [<00000000f2841faf>] krealloc+0x63/0xc0
    [<00000000ed643fb3>] regmap_register_patch+0x68/0x1d0
    [<000000001806a5c3>] 0xffffffffc088a5f9
    [<00000000f4781e26>] i2c_device_probe+0x462/0x4b0
    [<000000009dd7f5f4>] really_probe+0x17f/0x520
    [<00000000be42920d>] driver_probe_device+0x114/0x170
    [<00000000e5840d3f>] device_driver_attach+0x82/0x90
    [<0000000027828801>] __driver_attach+0xa9/0x190
    [<0000000085195e73>] bus_for_each_dev+0xe1/0x140
    [<0000000070edb38c>] bus_add_driver+0x224/0x2e0
    [<000000002d41b24a>] driver_register+0xd3/0x150
    [<0000000055dbb3fb>] i2c_register_driver+0x6b/0xd0
    [<00000000bf84b954>] do_one_initcall+0x86/0x2a0
    [<000000001d939871>] do_init_module+0xf8/0x350
    [<00000000267b474f>] load_module+0x41a9/0x44c0
    [<000000007d8014dc>] __do_sys_finit_module+0x121/0x1b0

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@...ux.intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta@...il.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@...ux.intel.com>
Reviewed-by: Rander Wang <rander.wang@...ux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@...ux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@...ux.intel.com>
---
 drivers/base/regmap/regmap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index c472f624382d..46f4b6322e47 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1357,6 +1357,7 @@ void regmap_exit(struct regmap *map)
 	if (map->hwlock)
 		hwspin_lock_free(map->hwlock);
 	kfree_const(map->name);
+	kfree(map->patch);
 	kfree(map);
 }
 EXPORT_SYMBOL_GPL(regmap_exit);
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ