Skip to content

Commit a4df83a

Browse files
nizhen-tgregkh
authored andcommitted
memory: samsung: exynos-srom: Fix of_iomap leak in exynos_srom_probe
commit 6744085 upstream. The of_platform_populate() call at the end of the function has a possible failure path, causing a resource leak. Replace of_iomap() with devm_platform_ioremap_resource() to ensure automatic cleanup of srom->reg_base. This issue was detected by smatch static analysis: drivers/memory/samsung/exynos-srom.c:155 exynos_srom_probe()warn: 'srom->reg_base' from of_iomap() not released on lines: 155. Fixes: 8ac2266 ("memory: samsung: exynos-srom: Add support for bank configuration") Cc: [email protected] Signed-off-by: Zhen Ni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b322ea3 commit a4df83a

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/memory/samsung/exynos-srom.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,20 +121,18 @@ static int exynos_srom_probe(struct platform_device *pdev)
121121
return -ENOMEM;
122122

123123
srom->dev = dev;
124-
srom->reg_base = of_iomap(np, 0);
125-
if (!srom->reg_base) {
124+
srom->reg_base = devm_platform_ioremap_resource(pdev, 0);
125+
if (IS_ERR(srom->reg_base)) {
126126
dev_err(&pdev->dev, "iomap of exynos srom controller failed\n");
127-
return -ENOMEM;
127+
return PTR_ERR(srom->reg_base);
128128
}
129129

130130
platform_set_drvdata(pdev, srom);
131131

132132
srom->reg_offset = exynos_srom_alloc_reg_dump(exynos_srom_offsets,
133133
ARRAY_SIZE(exynos_srom_offsets));
134-
if (!srom->reg_offset) {
135-
iounmap(srom->reg_base);
134+
if (!srom->reg_offset)
136135
return -ENOMEM;
137-
}
138136

139137
for_each_child_of_node(np, child) {
140138
if (exynos_srom_configure_bank(srom, child)) {

0 commit comments

Comments
 (0)