diff options
author | Pawel Moll <pawel.moll@arm.com> | 2014-07-31 11:16:37 -0400 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2014-07-31 23:46:57 -0400 |
commit | 3e528cb7bae00ba0d73def6645d0f2fa906ee3e8 (patch) | |
tree | f6b31134fdf241f9b1f371faf84a951aed00bc8a /drivers/bus | |
parent | f64a3c895bce1c703e706b8ee0badb39918c7dee (diff) |
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.c | 9 |
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) | |||
591 | struct arm_ccn *ccn; | 591 | struct arm_ccn *ccn; |
592 | struct hw_perf_event *hw = &event->hw; | 592 | struct hw_perf_event *hw = &event->hw; |
593 | u32 node_xp, type, event_id; | 593 | u32 node_xp, type, event_id; |
594 | int valid; | 594 | int valid, bit; |
595 | struct arm_ccn_component *source; | 595 | struct arm_ccn_component *source; |
596 | int i; | 596 | int i; |
597 | 597 | ||
@@ -713,17 +713,18 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) | |||
713 | 713 | ||
714 | /* Allocate an event source or a watchpoint */ | 714 | /* Allocate an event source or a watchpoint */ |
715 | if (type == CCN_TYPE_XP && event_id == CCN_EVENT_WATCHPOINT) | 715 | if (type == CCN_TYPE_XP && event_id == CCN_EVENT_WATCHPOINT) |
716 | hw->config_base = arm_ccn_pmu_alloc_bit(source->xp.dt_cmp_mask, | 716 | bit = arm_ccn_pmu_alloc_bit(source->xp.dt_cmp_mask, |
717 | CCN_NUM_XP_WATCHPOINTS); | 717 | CCN_NUM_XP_WATCHPOINTS); |
718 | else | 718 | else |
719 | hw->config_base = arm_ccn_pmu_alloc_bit(source->pmu_events_mask, | 719 | bit = arm_ccn_pmu_alloc_bit(source->pmu_events_mask, |
720 | CCN_NUM_PMU_EVENTS); | 720 | CCN_NUM_PMU_EVENTS); |
721 | if (hw->config_base < 0) { | 721 | if (bit < 0) { |
722 | dev_warn(ccn->dev, "No more event sources/watchpoints on node/XP %d!\n", | 722 | dev_warn(ccn->dev, "No more event sources/watchpoints on node/XP %d!\n", |
723 | node_xp); | 723 | node_xp); |
724 | clear_bit(hw->idx, ccn->dt.pmu_counters_mask); | 724 | clear_bit(hw->idx, ccn->dt.pmu_counters_mask); |
725 | return -EAGAIN; | 725 | return -EAGAIN; |
726 | } | 726 | } |
727 | hw->config_base = bit; | ||
727 | 728 | ||
728 | ccn->dt.pmu_counters[hw->idx].event = event; | 729 | ccn->dt.pmu_counters[hw->idx].event = event; |
729 | 730 | ||