Skip to content

Commit 0f7ca6f

Browse files
zijun-hurobherring
authored andcommitted
of/irq: Fix using uninitialized variable @addr_len in API of_irq_parse_one()
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: b739dff ("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>
1 parent fec3edc commit 0f7ca6f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/of/irq.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
355355
return of_irq_parse_oldworld(device, index, out_irq);
356356

357357
/* Get the reg property (if any) */
358+
addr_len = 0;
358359
addr = of_get_property(device, "reg", &addr_len);
359360

360361
/* Prevent out-of-bounds read in case of longer interrupt parent address size */

0 commit comments

Comments
 (0)