Commit 685d84a7 authored by Jonathan Zhou's avatar Jonathan Zhou Committed by Greg Kroah-Hartman

coresight: etm4x: Fix mis-usage of nr_resource in sysfs interface

The member @nr_resource represents how many resource selector pairs,
and the pair 0 is always implemented and reserved.
So let's multiply by 2 when resetting the selector configuration.
And also update the validation of the input @idx.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
Signed-off-by: default avatarJonathan Zhou <jonathan.zhouwen@huawei.com>
[Fixed typographical error in changelog, added stable]
Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20200916191737.4001561-16-mathieu.poirier@linaro.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6d578258
...@@ -236,7 +236,7 @@ static ssize_t reset_store(struct device *dev, ...@@ -236,7 +236,7 @@ static ssize_t reset_store(struct device *dev,
} }
config->res_idx = 0x0; config->res_idx = 0x0;
for (i = 0; i < drvdata->nr_resource; i++) for (i = 2; i < 2 * drvdata->nr_resource; i++)
config->res_ctrl[i] = 0x0; config->res_ctrl[i] = 0x0;
config->ss_idx = 0x0; config->ss_idx = 0x0;
...@@ -1663,8 +1663,11 @@ static ssize_t res_idx_store(struct device *dev, ...@@ -1663,8 +1663,11 @@ static ssize_t res_idx_store(struct device *dev,
if (kstrtoul(buf, 16, &val)) if (kstrtoul(buf, 16, &val))
return -EINVAL; return -EINVAL;
/* Resource selector pair 0 is always implemented and reserved */ /*
if ((val == 0) || (val >= drvdata->nr_resource)) * Resource selector pair 0 is always implemented and reserved,
* namely an idx with 0 and 1 is illegal.
*/
if ((val < 2) || (val >= 2 * drvdata->nr_resource))
return -EINVAL; return -EINVAL;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment