]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bus: sunxi-rsb: Always check register address validity
authorSamuel Holland <samuel@sholland.org>
Sun, 1 Mar 2026 14:49:39 +0000 (17:49 +0300)
committerChen-Yu Tsai <wens@kernel.org>
Sun, 24 May 2026 22:37:11 +0000 (06:37 +0800)
The register address was already validated for read operations in
regmap_sunxi_rsb_reg_read before being truncated to a u8. Write operations
have the same set of possible addresses, and the address is being truncated
from u32 to u8 here as well, so the same check is needed.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Fixes: d787dcdb9c8f ("bus: sunxi-rsb: Add driver for Allwinner Reduced Serial Bus")
Reviewed-by: Chen-Yu Tsai <wens@kernel.org>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Link: https://patch.msgid.link/20260301144939.1832806-1-andrej.skvortzov@gmail.com
Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
drivers/bus/sunxi-rsb.c

index b4f2c64ac1810ffc51521ecc82e00038b741a705..daf0ea563e47733279e5cd128271f3e743857b0e 100644 (file)
@@ -445,6 +445,9 @@ static int regmap_sunxi_rsb_reg_write(void *context, unsigned int reg,
        struct sunxi_rsb_ctx *ctx = context;
        struct sunxi_rsb_device *rdev = ctx->rdev;
 
+       if (reg > 0xff)
+               return -EINVAL;
+
        return sunxi_rsb_write(rdev->rsb, rdev->rtaddr, reg, &val, ctx->size);
 }