From 737cefc6e01bce091fa8b98bdca5f011d5801e40 Mon Sep 17 00:00:00 2001 From: spujar Date: Wed, 26 Sep 2018 20:33:12 +0530 Subject: [PATCH] tegra-alt: adsp: release socket in device remove Following error is seen during multiple unload/load of driver, Error creating socket tegra210-adsp: probe of tegra210-adsp failed with error -1 This is resulting in kernel panic and device reboot. Following is the crash, =============================================================================== Unable to handle kernel NULL pointer dereference at virtual address 00000010 Mem abort info: ESR = 0x96000005 Exception class = DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 Data abort info: ISV = 0, ISS = 0x00000005 CM = 0, WnR = 0 user pgtable: 4k pages, 39-bit VAs, pgd = ffffffc3e5a09000 [0000000000000010] *pgd=0000000000000000, *pud=0000000000000000 Internal error: Oops: 96000005 [#1] PREEMPT SMP PC is at soc_probe_component+0x90/0x350 LR is at soc_probe_component+0x34/0x350 pc : [] lr : [] pstate: 40400045 sp : ffffffc38bbab8c0 x29: ffffffc38bbab8c0 x28: 0000000000000000 x27: 0000000000000000 x26: ffffff80018f19b8 x25: ffffffc3e5acf800 x24: ffffffc3e8b44e00 x23: 00000000000000f8 x22: 0000000000000001 x21: ffffff80018f19b8 x20: ffffff800a067000 x19: ffffffc35b93aa50 x18: 000000003e48590c x17: 00000022d6c5fcd0 x16: ffffff8008153de0 x15: 0000000300000000 x14: 0000000000000000 x13: 0000000000000003 x12: 0000000000000026 x11: 0000000000000005 x10: 0101010101010101 x9 : 0000000000000000 x8 : 7f7f7f7f7f7f7f7f x7 : 2f30316071666473 x6 : 070b035f125d521d x5 : 1d525d125f030b07 x4 : 0000000000000000 x3 : 6dcc85ae6dec65a0 x2 : 000000000000008c x1 : ffffff80094aa810 x0 : 0000000000000000 Process insmod (pid: 5755, stack limit = 0xffffffc38bba8028) Call trace: [] soc_probe_component+0x90/0x350 [] snd_soc_instantiate_card+0x4d8/0xb58 [] snd_soc_register_card+0x15c/0x200 [] tegra_machine_driver_probe+0x3d0/0x5a0 [] platform_drv_probe+0x60/0xc8 [] driver_probe_device+0xd0/0x410 [] __driver_attach+0x124/0x128 [] bus_for_each_dev+0x88/0xe8 [] driver_attach+0x30/0x40 [] bus_add_driver+0x1f8/0x2b0 [] driver_register+0x68/0x100 [] __platform_driver_register+0x5c/0x68 [] tegra_asoc_machine_driver_init+0x18/0x30 [] do_one_initcall+0x5c/0x170 [] do_init_module+0x68/0x1b8 [] load_module+0x1004/0x1320 [] SyS_finit_module+0x110/0x128 [] el0_svc_naked+0x34/0x38 ---[ end trace 39fa2dd2a3c341ef ]--- =============================================================================== Fix info, This patch releases the socket in device removal and adsp probe succeeds Thus avoid above crash during sound card registration. Bug 200453666 Change-Id: Idb113b9aca71f830cd33cd8f9c3d742ad86280bb Signed-off-by: spujar Reviewed-on: https://git-master.nvidia.com/r/1847927 Reviewed-by: Ravindra Lokhande Reviewed-by: svc-mobile-coverity GVS: Gerrit_Virtual_Submit Reviewed-by: mobile promotions Tested-by: mobile promotions --- sound/soc/tegra-alt/tegra210_adsp_alt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/tegra-alt/tegra210_adsp_alt.c b/sound/soc/tegra-alt/tegra210_adsp_alt.c index 1bde0d5a..60350ff3 100644 --- a/sound/soc/tegra-alt/tegra210_adsp_alt.c +++ b/sound/soc/tegra-alt/tegra210_adsp_alt.c @@ -5715,6 +5715,9 @@ err: static int tegra210_adsp_audio_platform_remove(struct platform_device *pdev) { + struct tegra210_adsp *adsp = dev_get_drvdata(&pdev->dev); + + netlink_kernel_release(adsp->nl_sk); pm_runtime_disable(&pdev->dev); tegra_pd_remove_device(&pdev->dev); snd_soc_unregister_platform(&pdev->dev);