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

Commit ceb2271a authored by Manohar Vavilapalli's avatar Manohar Vavilapalli
Browse files

coresight-etm4x: Add size check before using Array 'addr_type'



Add size check to avoid Array Index out of bound Exception.

Change-Id: I03a290ed703e18fc4b53785950c77ad52de1dd94
Signed-off-by: default avatarManohar Vavilapalli <mvavilap@codeaurora.org>
parent 2f49ba7e
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@ static int etm4_set_mode_exclude(struct etmv4_drvdata *drvdata, bool exclude)

	idx = config->addr_idx;

	if (idx >= ETM_MAX_SINGLE_ADDR_CMP)
		return -EINVAL;

	/*
	 * TRCACATRn.TYPE bit[1:0]: type of comparison
	 * the trace unit performs
@@ -955,6 +958,9 @@ static ssize_t addr_range_show(struct device *dev,

	spin_lock(&drvdata->spinlock);
	idx = config->addr_idx;

	if (idx >= ETM_MAX_SINGLE_ADDR_CMP)
		return -EINVAL;
	if (idx % 2 != 0) {
		spin_unlock(&drvdata->spinlock);
		return -EPERM;
@@ -990,6 +996,9 @@ static ssize_t addr_range_store(struct device *dev,

	spin_lock(&drvdata->spinlock);
	idx = config->addr_idx;

	if (idx >= ETM_MAX_SINGLE_ADDR_CMP)
		return -EINVAL;
	if (idx % 2 != 0) {
		spin_unlock(&drvdata->spinlock);
		return -EPERM;