linux/drivers/memory/tegra
Joe Hattori c3def10c61 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-03-13 12:50:05 +01:00
..
Kconfig memory: tegra20-emc: Support matching timings by LPDDR2 configuration 2025-03-13 12:50:05 +01:00
Makefile memory: tegra: Split Tegra194 data into separate file 2021-06-03 21:49:41 +02:00
mc.c memory: tegra: Implement SID override programming 2021-06-03 21:50:43 +02:00
mc.h memory: tegra: Split Tegra194 data into separate file 2021-06-03 21:49:41 +02:00
tegra20-emc.c memory: tegra20-emc: fix an OF node reference bug in tegra_emc_find_node_by_ram_code() 2025-03-13 12:50:05 +01:00
tegra20.c memory: tegra: Parameterize interrupt handler 2021-06-03 21:49:41 +02:00
tegra30-emc.c memory: tegra: Delete dead debugfs checking code 2021-06-10 09:18:15 +02:00
tegra30.c memory: tegra: Extract setup code into callback 2021-06-03 21:49:41 +02:00
tegra114.c memory: tegra: Extract setup code into callback 2021-06-03 21:49:41 +02:00
tegra124-emc.c memory: tegra: Delete dead debugfs checking code 2021-06-10 09:18:15 +02:00
tegra124.c memory: tegra: Extract setup code into callback 2021-06-03 21:49:41 +02:00
tegra186-emc.c memory: tegra186-emc: Replace DEFINE_SIMPLE_ATTRIBUTE with DEFINE_DEBUGFS_ATTRIBUTE 2021-02-08 18:15:45 +01:00
tegra186.c memory: tegra: Skip SID programming if SID registers aren't set 2024-09-04 13:23:23 +02:00
tegra194.c memory: tegra: Split Tegra194 data into separate file 2021-06-03 21:49:41 +02:00
tegra210-emc-cc-r21021.c memory: tegra: Delete duplicated argument to '|' in function tegra210_emc_r21021_periodic_compensation 2020-09-09 09:00:22 +02:00
tegra210-emc-core.c memory: tegra: Delete dead debugfs checking code 2021-06-10 09:18:15 +02:00
tegra210-emc-table.c memory: tegra: Support derated timings on Tegra210 2020-06-22 13:54:57 +02: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