summaryrefslogtreecommitdiff
path: root/drivers/of
diff options
context:
space:
mode:
authorZijun Hu <quic_zijuhu@quicinc.com>2024-12-09 21:25:02 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-12-27 13:53:00 +0100
commit4c300be8835c4608767fe31928844dc8ddf85bfb (patch)
tree1ebb202f633200aff22c7abb377ef70126ac1cb1 /drivers/of
parentcd126daadfe289dfccee90cf1f63fa1d62efeb73 (diff)
downloadlinux-4c300be8835c4608767fe31928844dc8ddf85bfb.tar.gz
linux-4c300be8835c4608767fe31928844dc8ddf85bfb.tar.bz2
linux-4c300be8835c4608767fe31928844dc8ddf85bfb.zip
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>
Diffstat (limited to 'drivers/of')
-rw-r--r--drivers/of/irq.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 584e25aad649..8d77566eae1a 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -355,6 +355,7 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
return of_irq_parse_oldworld(device, index, out_irq);
/* Get the reg property (if any) */
+ addr_len = 0;
addr = of_get_property(device, "reg", &addr_len);
/* Prevent out-of-bounds read in case of longer interrupt parent address size */