Skip to content

Commit 3f05010

Browse files
Aidan MacDonaldbroonie
authored andcommitted
regmap-irq: Fix offset/index mismatch in read_sub_irq_data()
We need to divide the sub-irq status register offset by register stride to get an index for the status buffer to avoid an out of bounds write when the register stride is greater than 1. Fixes: a2d2184 ("regmap: regmap-irq: Add main status register support") Signed-off-by: Aidan MacDonald <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 485037a commit 3f05010

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/base/regmap/regmap-irq.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ static inline int read_sub_irq_data(struct regmap_irq_chip_data *data,
387387
subreg = &chip->sub_reg_offsets[b];
388388
for (i = 0; i < subreg->num_regs; i++) {
389389
unsigned int offset = subreg->offset[i];
390+
unsigned int index = offset / map->reg_stride;
390391

391392
if (chip->not_fixed_stride)
392393
ret = regmap_read(map,
@@ -395,7 +396,7 @@ static inline int read_sub_irq_data(struct regmap_irq_chip_data *data,
395396
else
396397
ret = regmap_read(map,
397398
chip->status_base + offset,
398-
&data->status_buf[offset]);
399+
&data->status_buf[index]);
399400

400401
if (ret)
401402
break;

0 commit comments

Comments
 (0)