]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
of/irq: Fix using uninitialized variable @addr_len in API of_irq_parse_one()
authorZijun Hu <quic_zijuhu@quicinc.com>
Mon, 9 Dec 2024 13:25:02 +0000 (21:25 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jan 2025 12:24:54 +0000 (13:24 +0100)
commit8d42147c83ee294ec3e0db207895dc6f4d273904
treef0c9dbc5a4a2e52ab82993c64edaa93fb466d1e2
parent64ee07cfd50f459e59ce0073893c669e290c5cc6
of/irq: Fix using uninitialized variable @addr_len in API of_irq_parse_one()

commit 0f7ca6f69354e0c3923bbc28c92d0ecab4d50a3e upstream.

of_irq_parse_one() may use uninitialized variable @addr_len as shown below:

// @addr_len is uninitialized
int addr_len;

// This operation does not touch @addr_len if it fails.
addr = of_get_property(device, "reg", &addr_len);

// Use uninitialized @addr_len if the operation fails.
if (addr_len > sizeof(addr_buf))
addr_len = sizeof(addr_buf);

// Check the operation result here.
if (addr)
memcpy(addr_buf, addr, addr_len);

Fix by initializing @addr_len before the operation.

Fixes: b739dffa5d57 ("of/irq: Prevent device address out-of-bounds read in interrupt map walk")
Cc: stable@vger.kernel.org
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20241209-of_irq_fix-v1-4-782f1419c8a1@quicinc.com
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/of/irq.c