public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] mailbox/tegra-hsp: Use after free in tegra_hsp_remove_doorbells()
@ 2016-11-18 11:34 Dan Carpenter
  2016-11-18 13:31 ` Thierry Reding
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-11-18 11:34 UTC (permalink / raw)
  To: Jassi Brar, Thierry Reding
  Cc: Stephen Warren, Alexandre Courbot,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

We have to use the _safe version of list_for_each() because we're
freeing the pointer as we go along.  (This might not show up testing
depending on what config options you have enabled).

Fixes: ed65ee43e397 ("mailbox: Add Tegra HSP driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/mailbox/tegra-hsp.c b/drivers/mailbox/tegra-hsp.c
index 17b256a..87be8d3 100644
--- a/drivers/mailbox/tegra-hsp.c
+++ b/drivers/mailbox/tegra-hsp.c
@@ -397,12 +397,12 @@ static struct mbox_chan *of_tegra_hsp_xlate(struct mbox_controller *mbox,
 
 static void tegra_hsp_remove_doorbells(struct tegra_hsp *hsp)
 {
-	struct tegra_hsp_doorbell *db;
+	struct tegra_hsp_doorbell *db, *tmp;
 	unsigned long flags;
 
 	spin_lock_irqsave(&hsp->lock, flags);
 
-	list_for_each_entry(db, &hsp->doorbells, list)
+	list_for_each_entry_safe(db, tmp, &hsp->doorbells, list)
 		__tegra_hsp_doorbell_destroy(db);
 
 	spin_unlock_irqrestore(&hsp->lock, flags);

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

* Re: [patch] mailbox/tegra-hsp: Use after free in tegra_hsp_remove_doorbells()
  2016-11-18 11:34 [patch] mailbox/tegra-hsp: Use after free in tegra_hsp_remove_doorbells() Dan Carpenter
@ 2016-11-18 13:31 ` Thierry Reding
  0 siblings, 0 replies; 2+ messages in thread
From: Thierry Reding @ 2016-11-18 13:31 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jassi Brar, Stephen Warren, Alexandre Courbot,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 552 bytes --]

On Fri, Nov 18, 2016 at 02:34:10PM +0300, Dan Carpenter wrote:
> We have to use the _safe version of list_for_each() because we're
> freeing the pointer as we go along.  (This might not show up testing
> depending on what config options you have enabled).
> 
> Fixes: ed65ee43e397 ("mailbox: Add Tegra HSP driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Good catch! I've applied this on top of the original driver patch that
Jassi acked earlier and I updated the Fixes: line with the new commit
SHA1.

Thanks,
Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

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

end of thread, other threads:[~2016-11-18 13:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-18 11:34 [patch] mailbox/tegra-hsp: Use after free in tegra_hsp_remove_doorbells() Dan Carpenter
2016-11-18 13:31 ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox