All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] regmap-irq: Fix dereference of a potentially null d->virt_buf
@ 2021-04-06 16:40 Colin King
  2021-04-07 20:26 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-04-06 16:40 UTC (permalink / raw)
  To: Mark Brown, Greg Kroah-Hartman, Rafael J . Wysocki, Guru Das Srinagesh
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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: 4c5014456305 ("regmap-irq: Introduce virtual regs to handle more config regs")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/base/regmap/regmap-irq.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index e6343ccc6aa1..760296a4b606 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -901,9 +901,11 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
 	kfree(d->mask_buf);
 	kfree(d->status_buf);
 	kfree(d->status_reg_buf);
-	for (i = 0; i < chip->num_virt_regs; i++)
-		kfree(d->virt_buf[i]);
-	kfree(d->virt_buf);
+	if (d->virt_buf) {
+		for (i = 0; i < chip->num_virt_regs; i++)
+			kfree(d->virt_buf[i]);
+		kfree(d->virt_buf);
+	}
 	kfree(d);
 	return ret;
 }
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] regmap-irq: Fix dereference of a potentially null d->virt_buf
  2021-04-06 16:40 [PATCH][next] regmap-irq: Fix dereference of a potentially null d->virt_buf Colin King
@ 2021-04-07 20:26 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2021-04-07 20:26 UTC (permalink / raw)
  To: Colin King, Guru Das Srinagesh, Rafael J . Wysocki, Greg Kroah-Hartman
  Cc: Mark Brown, linux-kernel, kernel-janitors

On Tue, 6 Apr 2021 17:40:02 +0100, Colin King wrote:
> 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.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] regmap-irq: Fix dereference of a potentially null d->virt_buf
      commit: 14e13b1ce92ea278fc0d7bb95b340b46cff624ab

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-04-07 20:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06 16:40 [PATCH][next] regmap-irq: Fix dereference of a potentially null d->virt_buf Colin King
2021-04-07 20:26 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.