Commit 5c709b37 authored by Felix Gu's avatar Felix Gu Committed by Borislav Petkov (AMD)
Browse files

EDAC/versalnet: Fix device_node leak in mc_probe()



of_parse_phandle() returns a device_node reference that must be released with
of_node_put(). The original code never freed r5_core_node on any exit path,
causing a memory leak.

Fix this by using the automatic cleanup attribute __free(device_node) which
ensures of_node_put() is called when the variable goes out of scope.

Fixes: d5fe2fec ("EDAC: Add a driver for the AMD Versal NET DDR controller")
Signed-off-by: default avatarFelix Gu <ustc.gu@gmail.com>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: default avatarShubhrajyoti Datta <shubhrajyoti.datta@amd.com>
Cc: <stable@kernel.org>
Link: https://patch.msgid.link/20260323-versalnet-v1-1-4ab3012635ef@gmail.com
parent 1b6f292c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -888,12 +888,12 @@ static void remove_versalnet(struct mc_priv *priv)

static int mc_probe(struct platform_device *pdev)
{
	struct device_node *r5_core_node;
	struct mc_priv *priv;
	struct rproc *rp;
	int rc;

	r5_core_node = of_parse_phandle(pdev->dev.of_node, "amd,rproc", 0);
	struct device_node *r5_core_node __free(device_node) =
		of_parse_phandle(pdev->dev.of_node, "amd,rproc", 0);
	if (!r5_core_node) {
		dev_err(&pdev->dev, "amd,rproc: invalid phandle\n");
		return -EINVAL;