Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 81f3b9aa authored by Mukesh Ojha's avatar Mukesh Ojha
Browse files

coresight-tmc: Adds lock to avoid race condition



There can be a case of race in the call to tmc_etr_bam_disable(). The call
from usb_notifier() to tmc_etr_bam_disable() is within a lock
'drvdata->mem_lock' but the call from tmc_disable is not under any lock
which can lead to race.

This patch adds the missing lock.

CRs-Fixed: 2047196
Change-Id: I3986b498ae8e2b2ddfe8f5b3315fdefab197d11c
Signed-off-by: default avatarMukesh Ojha <mojha@codeaurora.org>
parent 5404e350
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1018,6 +1018,7 @@ static void tmc_disable(struct tmc_drvdata *drvdata, enum tmc_mode mode)
{
	unsigned long flags;

	mutex_lock(&drvdata->mem_lock);
	spin_lock_irqsave(&drvdata->spinlock, flags);
	if (drvdata->reading)
		goto out;
@@ -1054,7 +1055,7 @@ out:
	}

	pm_runtime_put(drvdata->dev);

	mutex_unlock(&drvdata->mem_lock);
	dev_info(drvdata->dev, "TMC disabled\n");
}