summaryrefslogtreecommitdiffstats
path: root/drivers/bus
diff options
context:
space:
mode:
authorPawel Moll <pawel.moll@arm.com>2014-07-31 17:16:37 +0200
committerOlof Johansson <olof@lixom.net>2014-08-01 05:46:57 +0200
commit3e528cb7bae00ba0d73def6645d0f2fa906ee3e8 (patch)
treef6b31134fdf241f9b1f371faf84a951aed00bc8a /drivers/bus
parentMerge tag 'omap-for-v3.17/mailbox-cleanup' of git://git.kernel.org/pub/scm/li... (diff)
downloadlinux-3e528cb7bae00ba0d73def6645d0f2fa906ee3e8.tar.xz
linux-3e528cb7bae00ba0d73def6645d0f2fa906ee3e8.zip
bus: arm-ccn: Fix error handling at event allocation
The bitfield allocation function returns error condition as a negative value, but in two cases its result was assigned to an unsigned member of the hw_perf_event structure, thus the error would not be ever detected. Fixed by using an intermediate, signed variable. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Pawel Moll <pawel.moll@arm.com> Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'drivers/bus')
-rw-r--r--drivers/bus/arm-ccn.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c
index 4f86bbb2fac5..3266f8ff9311 100644
--- a/drivers/bus/arm-ccn.c
+++ b/drivers/bus/arm-ccn.c
@@ -591,7 +591,7 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
struct arm_ccn *ccn;
struct hw_perf_event *hw = &event->hw;
u32 node_xp, type, event_id;
- int valid;
+ int valid, bit;
struct arm_ccn_component *source;
int i;
@@ -713,17 +713,18 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
/* Allocate an event source or a watchpoint */
if (type == CCN_TYPE_XP && event_id == CCN_EVENT_WATCHPOINT)
- hw->config_base = arm_ccn_pmu_alloc_bit(source->xp.dt_cmp_mask,
+ bit = arm_ccn_pmu_alloc_bit(source->xp.dt_cmp_mask,
CCN_NUM_XP_WATCHPOINTS);
else
- hw->config_base = arm_ccn_pmu_alloc_bit(source->pmu_events_mask,
+ bit = arm_ccn_pmu_alloc_bit(source->pmu_events_mask,
CCN_NUM_PMU_EVENTS);
- if (hw->config_base < 0) {
+ if (bit < 0) {
dev_warn(ccn->dev, "No more event sources/watchpoints on node/XP %d!\n",
node_xp);
clear_bit(hw->idx, ccn->dt.pmu_counters_mask);
return -EAGAIN;
}
+ hw->config_base = bit;
ccn->dt.pmu_counters[hw->idx].event = event;