Skip to content

Commit 14e13b1

Browse files
Colin Ian Kingbroonie
authored andcommitted
regmap-irq: Fix dereference of a potentially null d->virt_buf
The clean up of struct d can potentiallly index into a null array d->virt_buf causing errorenous pointer dereferencing issues on kfree calls. Fix this by adding a null check on d->virt_buf before attempting to traverse the array to kfree the objects. Addresses-Coverity: ("Dereference after null check") Fixes: 4c50144 ("regmap-irq: Introduce virtual regs to handle more config regs") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: https://lore.kernel.org/r/20210406164002.430221-1-colin.king@canonical.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 394409a commit 14e13b1

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/base/regmap/regmap-irq.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,9 +901,11 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
901901
kfree(d->mask_buf);
902902
kfree(d->status_buf);
903903
kfree(d->status_reg_buf);
904-
for (i = 0; i < chip->num_virt_regs; i++)
905-
kfree(d->virt_buf[i]);
906-
kfree(d->virt_buf);
904+
if (d->virt_buf) {
905+
for (i = 0; i < chip->num_virt_regs; i++)
906+
kfree(d->virt_buf[i]);
907+
kfree(d->virt_buf);
908+
}
907909
kfree(d);
908910
return ret;
909911
}

0 commit comments

Comments
 (0)