From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: "Shaik, ShahinaX" Date: Thu, 29 Mar 2018 21:40:15 +0530 Subject: [PATCH] ASoC: Intel: Skylake: Fix Audio memory leakage at boot time Fix kmemleak issues in skl_module_sysfs_init functions by, instead of allocating memory, we use local variable of type "char array" and snprintf to write uuid. kmemleak backtrace: unreferenced object 0xffff880267946e00 (size 64): comm "insmod", pid 2340, jiffies 4294672904 (age 92.133s) hex dump (first 32 bytes): 36 36 42 34 34 30 32 44 2d 42 34 36 38 2d 34 32 66B4402D-B468-42 46 32 2d 38 31 41 37 2d 42 33 37 31 32 31 38 36 F2-81A7-B3712186 backtrace: [] kmemleak_alloc+0x4a/0xa0 [] __kmalloc_track_caller+0x124/0x200 [] kvasprintf+0x66/0xd0 [] kasprintf+0x4e/0x70 [] skl_module_sysfs_init+0x13a/0x260 [snd_soc_skl_ipc] [] skl_platform_soc_probe+0x246/0x480 [snd_soc_skl] [] snd_soc_platform_drv_probe+0x1c/0x20 [] soc_probe_component+0x227/0x3c0 [] snd_soc_register_card+0x687/0xf00 [] broxton_tdf8532_audio_probe+0x3a/0x3d [snd_soc_sst_bxt_tdf8532] [] platform_drv_probe+0x3e/0xa0 [] driver_probe_device+0xef/0x410 [] __driver_attach+0xa7/0xf0 [] bus_for_each_dev+0x70/0xc0 [] driver_attach+0x1e/0x20 [] bus_add_driver+0x1c7/0x270 Change-Id: Ib326d4400c0d7ac6cd4ad36a2dd006663837cee7 Signed-off-by: Shaik, ShahinaX Reviewed-on: Reviewed-by: Shaik, Kareem M Reviewed-by: Singh, Guneshwor O Reviewed-by: Babu, Ramesh Reviewed-by: Kale, Sanyog R Reviewed-by: Koul, Vinod Tested-by: Madiwalar, MadiwalappaX --- sound/soc/intel/skylake/skl-sst-utils.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/intel/skylake/skl-sst-utils.c b/sound/soc/intel/skylake/skl-sst-utils.c index 668e7d020a9c..7c867426b39b 100644 --- a/sound/soc/intel/skylake/skl-sst-utils.c +++ b/sound/soc/intel/skylake/skl-sst-utils.c @@ -1178,10 +1178,11 @@ int skl_module_sysfs_init(struct skl_sst *ctx, struct kobject *kobj) { struct uuid_module *module; struct skl_sysfs_module *modinfo_obj; - char *uuid_name; int count = 0; int max_mod = 0; int ret = 0; + unsigned int uuid_size = sizeof(module->uuid); + char uuid_name[uuid_size]; if (list_empty(&ctx->uuid_list)) return 0; @@ -1218,7 +1219,7 @@ int skl_module_sysfs_init(struct skl_sst *ctx, struct kobject *kobj) goto err_sysfs_exit; } - uuid_name = kasprintf(GFP_KERNEL, "%pUL", &module->uuid); + snprintf(uuid_name, sizeof(uuid_name), "%pUL", &module->uuid); ret = kobject_init_and_add(&modinfo_obj->kobj, &uuid_ktype, ctx->sysfs_tree->modules_kobj, uuid_name); if (ret < 0) @@ -1240,7 +1241,7 @@ int skl_module_sysfs_init(struct skl_sst *ctx, struct kobject *kobj) return 0; err_sysfs_exit: - skl_module_sysfs_exit(ctx); + skl_module_sysfs_exit(ctx); return ret; } -- https://clearlinux.org