]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
mailbox: tegra-hsp: Use after free in tegra_hsp_remove_doorbells()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 18 Nov 2016 11:34:10 +0000 (14:34 +0300)
committerThierry Reding <treding@nvidia.com>
Fri, 18 Nov 2016 13:32:13 +0000 (14:32 +0100)
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: 0fe88461a0ec ("mailbox: Add Tegra HSP driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/mailbox/tegra-hsp.c

index 3724f2fcd371dcbe99e8f57d5f2e94a4c8c7a5a1..0cde356c11abcb5cc0d1596e9ef0888acf883662 100644 (file)
@@ -334,12 +334,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);