ASoC: Memeory leak fixes
Subsystems (3)
cover ASoC: Memeory leak fixes
This series fixes two memeory leaks, first in topology core to freeup the objects in widget creation and second one on Skylake driver for NHLT table cleanup
Jeeja KP (2):
ASoC: topology: Fix memory leak in widget creation
ASoC: Intel: Skylake: Fix memory leak in nhlt init
sound/soc/intel/skylake/skl-nhlt.c | 15 +++++++++------ sound/soc/intel/skylake/skl.c | 5 ++++- sound/soc/intel/skylake/skl.h | 6 +++--- sound/soc/soc-topology.c | 2 ++ 4 files changed, 18 insertions(+), 10 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 ASoC: topology: Fix memory leak in widget creation
From: Jeeja KP <[email protected]>
name and sname allocated in widget create are not freed when creation is successful, so free them.
--- sound/soc/soc-topology.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/soc-topology.c +2 -0
@@ -1476,6 +1476,8 @@ widget: widget->dobj.type =SND_SOC_DOBJ_WIDGET ; widget->dobj.ops = tplg->ops; widget->dobj.index = tplg->index; +kfree (template.sname); +kfree (template.name);list_add (&widget->dobj.list, &tplg->comp->dobj_list);return 0 ;
Signature · 1 line
1.9.1
Mark Brown
maintainerApplied "ASoC: topology: Fix memory leak in widget creation" to the asoc tree
The patch
ASoC: topology: Fix memory leak in widget creation
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
8ea416748bb04b7a778cb8d2fd5ec7fa51b9d521Mon Sep 17 00:00:00 2001
From: Jeeja KP <[email protected]>
Date: Thu, 5 May 2016 11:19:18 +0530
Subject: [PATCH] ASoC: topology: Fix memory leak in widget creation
name and sname allocated in widget create are not freed when creation is successful, so free them.
--- sound/soc/soc-topology.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/soc-topology.c +2 -0
@@ -1481,6 +1481,8 @@ widget: widget->dobj.type =SND_SOC_DOBJ_WIDGET ; widget->dobj.ops = tplg->ops; widget->dobj.index = tplg->index; +kfree (template.sname); +kfree (template.name);list_add (&widget->dobj.list, &tplg->comp->dobj_list);return 0 ;
Signature · 1 line
2.8.1
PATCH 2/2 ASoC: Intel: Skylake: Fix memory leak in nhlt init
In reply to Vinod KoulFrom: Jeeja KP <[email protected]>
During skl_nhlt_init(), acpi obj pointer is allocated and never freed and remap address is not unmapped.
To fix this we should release the ACPI obj and also unmap the nhlt address during cleanup of driver.
--- sound/soc/intel/skylake/skl-nhlt.c | 15 +++++++++------ sound/soc/intel/skylake/skl.c | 5 ++++- sound/soc/intel/skylake/skl.h | 6 +++--- 3 files changed, 16 insertions(+), 10 deletions(-)
sound/soc/intel/skylake/skl-nhlt.c +9 -6
@@ -25,11 +25,12 @@ static u8 OSC_UUID[16] = {0x6E, 0x88, 0x9F, 0xA6, 0xEB, 0x6C, 0x94, 0x45,#define DSDT_NHLT_PATH "\\_SB.PCI0.HDAS" -void *skl_nhlt_init (struct device *dev) +struct nhlt_acpi_table *skl_nhlt_init (struct device *dev) {acpi_handle handle;union acpi_object *obj;struct nhlt_resource_desc *nhlt_ptr =NULL ; +struct nhlt_acpi_table *nhlt_table =NULL ;if (ACPI_FAILURE (acpi_get_handle (NULL ,DSDT_NHLT_PATH , &handle))) {dev_err (dev,"Requested NHLT device not found\n" );
@@ -39,18 +40,20 @@ void *skl_nhlt_init(struct device *dev) obj =acpi_evaluate_dsm (handle,OSC_UUID ,1 ,1 ,NULL );if (obj && obj->type ==ACPI_TYPE_BUFFER ) { nhlt_ptr = (struct nhlt_resource_desc *)obj->buffer.pointer; - -return memremap (nhlt_ptr->min_addr, nhlt_ptr->length, + nhlt_table = (struct nhlt_acpi_table *) +memremap (nhlt_ptr->min_addr, nhlt_ptr->length,MEMREMAP_WB ); +ACPI_FREE (obj); +return nhlt_table; }dev_err (dev,"device specific method to extract NHLT blob failed\n" );return NULL ; } -void skl_nhlt_free (void *addr) +void skl_nhlt_free (struct nhlt_acpi_table *nhlt) { -memunmap (addr); +memunmap ((void *) nhlt); } static struct nhlt_specific_cfg *skl_get_specific_cfg(
@@ -120,7 +123,7 @@ struct nhlt_specific_cfgstruct hdac_bus *bus =ebus_to_hbus (&skl->ebus);struct device *dev = bus->dev;struct nhlt_specific_cfg *sp_config; -struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt; +struct nhlt_acpi_table *nhlt = skl->nhlt;u16 bps = (s_fmt ==16 ) ?16 :32 ;u8 j;
sound/soc/intel/skylake/skl.c +4 -1
@@ -643,7 +643,7 @@ static int skl_probe(struct pci_dev *pci, err =skl_machine_device_register (skl, (void *)pci_id->driver_data);if (err <0 ) - goto out_free; + goto out_nhlt_free; err =skl_init_dsp (skl);if (err <0 ) {
@@ -693,6 +693,8 @@ out_dsp_free:skl_free_dsp (skl); out_mach_free:skl_machine_device_unregister (skl); +out_nhlt_free: +skl_nhlt_free (skl->nhlt); out_free: skl->init_failed =1 ;skl_free (ebus);
@@ -743,6 +745,7 @@ static void skl_remove(struct pci_dev *pci)skl_free_dsp (skl);skl_machine_device_unregister (skl);skl_dmic_device_unregister (skl); +skl_nhlt_free (skl->nhlt);skl_free (ebus);dev_set_drvdata (&pci->dev,NULL ); }
sound/soc/intel/skylake/skl.h +3 -3
@@ -66,7 +66,7 @@ struct skl {struct platform_device *dmic_dev;struct platform_device *i2s_dev; -void *nhlt;/* nhlt ptr */ +struct nhlt_acpi_table *nhlt;/* nhlt ptr */ struct skl_sst *skl_sst;/* sst skl ctx */ struct skl_dsp_resource resource;
@@ -103,8 +103,8 @@ struct skl_dsp_ops {int skl_platform_unregister (struct device *dev);int skl_platform_register (struct device *dev); -void *skl_nhlt_init (struct device *dev); -void skl_nhlt_free (void *addr); +struct nhlt_acpi_table *skl_nhlt_init (struct device *dev); +void skl_nhlt_free (struct nhlt_acpi_table *addr);struct nhlt_specific_cfg *skl_get_ep_blob (struct skl *skl,u32 instance,u8 link_type,u8 s_fmt,u8 no_ch,u32 s_rate,u8 dirn);
Signature · 1 line
1.9.1
Mark Brown
maintainerApplied "ASoC: Intel: Skylake: Fix memory leak in nhlt init" to the asoc tree
The patch
ASoC: Intel: Skylake: Fix memory leak in nhlt init
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
c286b3f9600b2ddc573208792d947e1a251c6b15Mon Sep 17 00:00:00 2001
From: Jeeja KP <[email protected]>
Date: Thu, 5 May 2016 11:19:19 +0530
Subject: [PATCH] ASoC: Intel: Skylake: Fix memory leak in nhlt init
During skl_nhlt_init(), acpi obj pointer is allocated and never freed and remap address is not unmapped.
To fix this we should release the ACPI obj and also unmap the nhlt address during cleanup of driver.
--- sound/soc/intel/skylake/skl-nhlt.c | 15 +++++++++------ sound/soc/intel/skylake/skl.c | 5 ++++- sound/soc/intel/skylake/skl.h | 6 +++--- 3 files changed, 16 insertions(+), 10 deletions(-)
sound/soc/intel/skylake/skl-nhlt.c +9 -6
@@ -25,11 +25,12 @@ static u8 OSC_UUID[16] = {0x6E, 0x88, 0x9F, 0xA6, 0xEB, 0x6C, 0x94, 0x45,#define DSDT_NHLT_PATH "\\_SB.PCI0.HDAS" -void *skl_nhlt_init (struct device *dev) +struct nhlt_acpi_table *skl_nhlt_init (struct device *dev) {acpi_handle handle;union acpi_object *obj;struct nhlt_resource_desc *nhlt_ptr =NULL ; +struct nhlt_acpi_table *nhlt_table =NULL ;if (ACPI_FAILURE (acpi_get_handle (NULL ,DSDT_NHLT_PATH , &handle))) {dev_err (dev,"Requested NHLT device not found\n" );
@@ -39,18 +40,20 @@ void *skl_nhlt_init(struct device *dev) obj =acpi_evaluate_dsm (handle,OSC_UUID ,1 ,1 ,NULL );if (obj && obj->type ==ACPI_TYPE_BUFFER ) { nhlt_ptr = (struct nhlt_resource_desc *)obj->buffer.pointer; - -return memremap (nhlt_ptr->min_addr, nhlt_ptr->length, + nhlt_table = (struct nhlt_acpi_table *) +memremap (nhlt_ptr->min_addr, nhlt_ptr->length,MEMREMAP_WB ); +ACPI_FREE (obj); +return nhlt_table; }dev_err (dev,"device specific method to extract NHLT blob failed\n" );return NULL ; } -void skl_nhlt_free (void *addr) +void skl_nhlt_free (struct nhlt_acpi_table *nhlt) { -memunmap (addr); +memunmap ((void *) nhlt); } static struct nhlt_specific_cfg *skl_get_specific_cfg(
@@ -120,7 +123,7 @@ struct nhlt_specific_cfgstruct hdac_bus *bus =ebus_to_hbus (&skl->ebus);struct device *dev = bus->dev;struct nhlt_specific_cfg *sp_config; -struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt; +struct nhlt_acpi_table *nhlt = skl->nhlt;u16 bps = (s_fmt ==16 ) ?16 :32 ;u8 j;
sound/soc/intel/skylake/skl.c +4 -1
@@ -643,7 +643,7 @@ static int skl_probe(struct pci_dev *pci, err =skl_machine_device_register (skl, (void *)pci_id->driver_data);if (err <0 ) - goto out_free; + goto out_nhlt_free; err =skl_init_dsp (skl);if (err <0 ) {
@@ -693,6 +693,8 @@ out_dsp_free:skl_free_dsp (skl); out_mach_free:skl_machine_device_unregister (skl); +out_nhlt_free: +skl_nhlt_free (skl->nhlt); out_free: skl->init_failed =1 ;skl_free (ebus);
@@ -743,6 +745,7 @@ static void skl_remove(struct pci_dev *pci)skl_free_dsp (skl);skl_machine_device_unregister (skl);skl_dmic_device_unregister (skl); +skl_nhlt_free (skl->nhlt);skl_free (ebus);dev_set_drvdata (&pci->dev,NULL ); }
sound/soc/intel/skylake/skl.h +3 -3
@@ -66,7 +66,7 @@ struct skl {struct platform_device *dmic_dev;struct platform_device *i2s_dev; -void *nhlt;/* nhlt ptr */ +struct nhlt_acpi_table *nhlt;/* nhlt ptr */ struct skl_sst *skl_sst;/* sst skl ctx */ struct skl_dsp_resource resource;
@@ -103,8 +103,8 @@ struct skl_dsp_ops {int skl_platform_unregister (struct device *dev);int skl_platform_register (struct device *dev); -void *skl_nhlt_init (struct device *dev); -void skl_nhlt_free (void *addr); +struct nhlt_acpi_table *skl_nhlt_init (struct device *dev); +void skl_nhlt_free (struct nhlt_acpi_table *addr);struct nhlt_specific_cfg *skl_get_ep_blob (struct skl *skl,u32 instance,u8 link_type,u8 s_fmt,u8 no_ch,u32 s_rate,u8 dirn);
Signature · 1 line
2.8.1