]> www.infradead.org Git - users/willy/xarray.git/commitdiff
of/irq: Refer to actual buffer size in of_irq_parse_one()
authorGeert Uytterhoeven <geert+renesas@glider.be>
Tue, 20 Aug 2024 12:16:53 +0000 (14:16 +0200)
committerRob Herring (Arm) <robh@kernel.org>
Mon, 26 Aug 2024 13:45:09 +0000 (08:45 -0500)
Replace two open-coded calculations of the buffer size by invocations of
sizeof() on the buffer itself, to make sure the code will always use the
actual buffer size.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/817c0b9626fd30790fc488c472a3398324cfcc0c.1724156125.git.geert+renesas@glider.be
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
drivers/of/irq.c

index cc30b471e446045af422d112cde57cd2a3fae320..36351ad6115eb10e2ef6c45e5b98e12a360adc27 100644 (file)
@@ -357,8 +357,8 @@ int of_irq_parse_one(struct device_node *device, int index, struct of_phandle_ar
        addr = of_get_property(device, "reg", &addr_len);
 
        /* Prevent out-of-bounds read in case of longer interrupt parent address size */
-       if (addr_len > (3 * sizeof(__be32)))
-               addr_len = 3 * sizeof(__be32);
+       if (addr_len > sizeof(addr_buf))
+               addr_len = sizeof(addr_buf);
        if (addr)
                memcpy(addr_buf, addr, addr_len);