Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 43aeffd

Browse files
krzkgregkh
authored andcommitted
soc: versatile: realview: fix memory leak during device remove
[ Upstream commit 1c4f26a ] If device is unbound, the memory allocated for soc_dev_attr should be freed to prevent leaks. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/20240825-soc-dev-fixes-v1-2-ff4b35abed83@linaro.org Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Stable-dep-of: c774f25 ("soc: versatile: realview: fix soc_dev leak during device remove") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d2b36e7 commit 43aeffd

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/soc/versatile/soc-realview.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static int realview_soc_probe(struct platform_device *pdev)
9393
if (IS_ERR(syscon_regmap))
9494
return PTR_ERR(syscon_regmap);
9595

96-
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
96+
soc_dev_attr = devm_kzalloc(&pdev->dev, sizeof(*soc_dev_attr), GFP_KERNEL);
9797
if (!soc_dev_attr)
9898
return -ENOMEM;
9999

@@ -106,10 +106,9 @@ static int realview_soc_probe(struct platform_device *pdev)
106106
soc_dev_attr->family = "Versatile";
107107
soc_dev_attr->custom_attr_group = realview_groups[0];
108108
soc_dev = soc_device_register(soc_dev_attr);
109-
if (IS_ERR(soc_dev)) {
110-
kfree(soc_dev_attr);
109+
if (IS_ERR(soc_dev))
111110
return -ENODEV;
112-
}
111+
113112
ret = regmap_read(syscon_regmap, REALVIEW_SYS_ID_OFFSET,
114113
&realview_coreid);
115114
if (ret)

0 commit comments

Comments
 (0)