This is a note to let you know that I've just added the patch titled memory: samsung: exynos5422-dmc: Fix refcount leak in of_get_dram_timings to the 5.18-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: memory-samsung-exynos5422-dmc-fix-refcount-leak-in-of_get_dram_timings.patch and it can be found in the queue-5.18 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 1332661e09304b7b8e84e5edc11811ba08d12abe Mon Sep 17 00:00:00 2001 From: Miaoqian Lin <linmq006@xxxxxxxxx> Date: Thu, 2 Jun 2022 08:17:21 +0400 Subject: memory: samsung: exynos5422-dmc: Fix refcount leak in of_get_dram_timings From: Miaoqian Lin <linmq006@xxxxxxxxx> commit 1332661e09304b7b8e84e5edc11811ba08d12abe upstream. of_parse_phandle() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. This function doesn't call of_node_put() in some error paths. To unify the structure, Add put_node label and goto it on errors. Fixes: 6e7674c3c6df ("memory: Add DMC driver for Exynos5422") Signed-off-by: Miaoqian Lin <linmq006@xxxxxxxxx> Reviewed-by: Lukasz Luba <lukasz.luba@xxxxxxx> Link: https://lore.kernel.org/r/20220602041721.64348-1-linmq006@xxxxxxxxx Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/memory/samsung/exynos5422-dmc.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) --- a/drivers/memory/samsung/exynos5422-dmc.c +++ b/drivers/memory/samsung/exynos5422-dmc.c @@ -1187,33 +1187,39 @@ static int of_get_dram_timings(struct ex dmc->timing_row = devm_kmalloc_array(dmc->dev, TIMING_COUNT, sizeof(u32), GFP_KERNEL); - if (!dmc->timing_row) - return -ENOMEM; + if (!dmc->timing_row) { + ret = -ENOMEM; + goto put_node; + } dmc->timing_data = devm_kmalloc_array(dmc->dev, TIMING_COUNT, sizeof(u32), GFP_KERNEL); - if (!dmc->timing_data) - return -ENOMEM; + if (!dmc->timing_data) { + ret = -ENOMEM; + goto put_node; + } dmc->timing_power = devm_kmalloc_array(dmc->dev, TIMING_COUNT, sizeof(u32), GFP_KERNEL); - if (!dmc->timing_power) - return -ENOMEM; + if (!dmc->timing_power) { + ret = -ENOMEM; + goto put_node; + } dmc->timings = of_lpddr3_get_ddr_timings(np_ddr, dmc->dev, DDR_TYPE_LPDDR3, &dmc->timings_arr_size); if (!dmc->timings) { - of_node_put(np_ddr); dev_warn(dmc->dev, "could not get timings from DT\n"); - return -EINVAL; + ret = -EINVAL; + goto put_node; } dmc->min_tck = of_lpddr3_get_min_tck(np_ddr, dmc->dev); if (!dmc->min_tck) { - of_node_put(np_ddr); dev_warn(dmc->dev, "could not get tck from DT\n"); - return -EINVAL; + ret = -EINVAL; + goto put_node; } /* Sorted array of OPPs with frequency ascending */ @@ -1227,13 +1233,14 @@ static int of_get_dram_timings(struct ex clk_period_ps); } - of_node_put(np_ddr); /* Take the highest frequency's timings as 'bypass' */ dmc->bypass_timing_row = dmc->timing_row[idx - 1]; dmc->bypass_timing_data = dmc->timing_data[idx - 1]; dmc->bypass_timing_power = dmc->timing_power[idx - 1]; +put_node: + of_node_put(np_ddr); return ret; } Patches currently in stable-queue which might be from linmq006@xxxxxxxxx are queue-5.18/memory-mtk-smi-add-missing-put_device-call-in-mtk_smi_device_link_common.patch queue-5.18/iio-adc-adi-axi-adc-fix-refcount-leak-in-adi_axi_adc_attach_client.patch queue-5.18/memory-samsung-exynos5422-dmc-fix-refcount-leak-in-of_get_dram_timings.patch queue-5.18/arm-fix-refcount-leak-in-axxia_boot_secondary.patch queue-5.18/drm-msm-mdp4-fix-refcount-leak-in-mdp4_modeset_init_.patch queue-5.18/arm-cns3xxx-fix-refcount-leak-in-cns3xxx_init.patch queue-5.18/iio-adc-aspeed-fix-refcount-leak-in-aspeed_adc_set_trim_data.patch queue-5.18/soc-bcm-brcmstb-pm-pm-arm-fix-refcount-leak-in-brcmstb_pm_probe.patch queue-5.18/arm-exynos-fix-refcount-leak-in-exynos_map_pmu.patch