From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44A7222A7F0; Mon, 13 Apr 2026 16:28:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776097723; cv=none; b=NcQDk+w5GVdvvyJ8T/0nIGEN7CuncP3clTN0yCWMRyKJGg6iknzu8YmvOABdc/QRkQF75sSf1vUo/N30MrBKBicizxitJDIPH2dEWyF+ypXXU7D9gVPgAKXCl/KyXWzhcMyY0ufNJso8mM83zHZhsoKNOv9rp03m3Kv7fQV6Wr4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776097723; c=relaxed/simple; bh=zj8EAiJJ0ToPMxVtMinIz0hpvSCw00I6R/qSzFUwiAo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CjpKBQB6n6N/SS3wWIB8bgeIrIwo5F8y11q6b713taaykgDqGYmjENPd1Q51z0YOLLdBiWXK5gcCzcMuCTHaGVT41YAKCzU9lr1s1xonc13E7gQXqCIMNxf98jqJ0H5DkrPNjcrI1GBq9cFnk165sXbtMTSLWlhU9kGC5UUWQco= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vPCIV6z6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="vPCIV6z6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCA6AC2BCAF; Mon, 13 Apr 2026 16:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776097723; bh=zj8EAiJJ0ToPMxVtMinIz0hpvSCw00I6R/qSzFUwiAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vPCIV6z6PwyEGbzIdvplPKJzM3ZQp27pi8x/J8V3PzxxCps9OEu0KkYOBAbpgBeWR atIQkqwojYgEZPXg5uEN3VB2YbEFc7Tic4TNyVLvAEoTqZN16WPvBHKjnDSvI0hSM+ rI7KQyiUaEFW3bT/f6+XeYdjSE9wRhYKVkJYB5J4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Felix Gu , Sudeep Holla , Sasha Levin Subject: [PATCH 5.15 247/570] firmware: arm_scpi: Fix device_node reference leak in probe path Date: Mon, 13 Apr 2026 17:56:18 +0200 Message-ID: <20260413155839.720400571@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260413155830.386096114@linuxfoundation.org> References: <20260413155830.386096114@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Felix Gu [ Upstream commit 879c001afbac3df94160334fe5117c0c83b2cf48 ] A device_node reference obtained from the device tree is not released on all error paths in the arm_scpi probe path. Specifically, a node returned by of_parse_phandle() could be leaked when the probe failed after the node was acquired. The probe function returns early and the shmem reference is not released. Use __free(device_node) scope-based cleanup to automatically release the reference when the variable goes out of scope. Fixes: ed7ecb883901 ("firmware: arm_scpi: Add compatibility checks for shmem node") Signed-off-by: Felix Gu Message-Id: <20260121-arm_scpi_2-v2-1-702d7fa84acb@gmail.com> Signed-off-by: Sudeep Holla Signed-off-by: Sasha Levin --- drivers/firmware/arm_scpi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c index 3de25e9d18ef8..2d85e783ae267 100644 --- a/drivers/firmware/arm_scpi.c +++ b/drivers/firmware/arm_scpi.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -945,13 +946,13 @@ static int scpi_probe(struct platform_device *pdev) int idx = scpi_drvinfo->num_chans; struct scpi_chan *pchan = scpi_drvinfo->channels + idx; struct mbox_client *cl = &pchan->cl; - struct device_node *shmem = of_parse_phandle(np, "shmem", idx); + struct device_node *shmem __free(device_node) = + of_parse_phandle(np, "shmem", idx); if (!of_match_node(shmem_of_match, shmem)) return -ENXIO; ret = of_address_to_resource(shmem, 0, &res); - of_node_put(shmem); if (ret) { dev_err(dev, "failed to get SCPI payload mem resource\n"); return ret; -- 2.51.0