linux/drivers/memory/tegra
Joe Hattori 3b02273446 memory: tegra20-emc: fix an OF node reference bug in tegra_emc_find_node_by_ram_code()
[ Upstream commit b9784e5cde ]

As of_find_node_by_name() release the reference of the argument device
node, tegra_emc_find_node_by_ram_code() releases some device nodes while
still in use, resulting in possible UAFs. According to the bindings and
the in-tree DTS files, the "emc-tables" node is always device's child
node with the property "nvidia,use-ram-code", and the "lpddr2" node is a
child of the "emc-tables" node. Thus utilize the
for_each_child_of_node() macro and of_get_child_by_name() instead of
of_find_node_by_name() to simplify the code.

This bug was found by an experimental verification tool that I am
developing.

Fixes: 96e5da7c84 ("memory: tegra: Introduce Tegra20 EMC driver")
Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Link: https://lore.kernel.org/r/20241217091434.1993597-1-joe@pf.is.s.u-tokyo.ac.jp
Link: https://lore.kernel.org/r/20241218024415.2494267-3-joe@pf.is.s.u-tokyo.ac.jp
[krzysztof: applied v1, adjust the commit msg to incorporate v2 parts]
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-02-08 09:57:41 +01:00
..
Kconfig memory: tegra30-emc: Print additional memory info 2022-01-27 10:40:34 +01:00
Makefile memory: tegra: Add Tegra234 support 2022-05-09 10:46:00 +02:00
mc.c memory: tegra-mc: simplify with scoped for each OF child loop 2024-08-21 13:23:34 +02:00
mc.h memory: tegra: Make CPU cluster BW request a multiple of MC channels 2023-05-16 12:11:01 +02:00
tegra20-emc.c memory: tegra20-emc: fix an OF node reference bug in tegra_emc_find_node_by_ram_code() 2025-02-08 09:57:41 +01:00
tegra20.c interconnect: constify of_phandle_args in xlate 2024-02-26 00:38:17 +02:00
tegra30-emc.c memory: tegra30-emc: simplify with scoped for each OF child loop 2024-08-21 13:23:35 +02:00
tegra30.c interconnect: constify of_phandle_args in xlate 2024-02-26 00:38:17 +02:00
tegra114.c memory: tegra: Extract setup code into callback 2021-06-03 21:49:41 +02:00
tegra124-emc.c memory: tegra124-emc: simplify with scoped for each OF child loop 2024-08-21 13:23:34 +02:00
tegra124.c interconnect: constify of_phandle_args in xlate 2024-02-26 00:38:17 +02:00
tegra186-emc.c memory: tegra186-emc: drop unused to_tegra186_emc() 2024-08-14 16:16:41 +02:00
tegra186.c IOMMU Updates for Linux v6.8 2024-01-18 15:16:57 -08:00
tegra194.c memory: tegra: Add dummy implementation on Tegra194 2023-07-10 12:04:56 +02:00
tegra210-emc-cc-r21021.c memory: tegra: Rework update_clock_tree_delay() 2024-07-29 17:35:21 +02:00
tegra210-emc-core.c memory: tegra210-emc: Convert to platform remove callback returning void 2023-12-19 09:05:19 +01:00
tegra210-emc-table.c memory: tegra: remove redundant variable initialization 2023-03-22 18:48:46 +01:00
tegra210-emc.h memory: tegra: Drop <linux/clk-provider.h> 2020-06-22 13:54:58 +02:00
tegra210-mc.h memory: tegra: Add EMC scaling support code for Tegra210 2020-06-22 13:54:57 +02:00
tegra210.c memory: tegra: Extract setup code into callback 2021-06-03 21:49:41 +02:00
tegra234.c memory: tegra: Fix indentation 2024-02-22 09:48:53 +01:00