Commit 3e528cb7 authored by Pawel Moll's avatar Pawel Moll Committed by Olof Johansson

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarPawel Moll <pawel.moll@arm.com>
Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
parent f64a3c89
...@@ -591,7 +591,7 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) ...@@ -591,7 +591,7 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
struct arm_ccn *ccn; struct arm_ccn *ccn;
struct hw_perf_event *hw = &event->hw; struct hw_perf_event *hw = &event->hw;
u32 node_xp, type, event_id; u32 node_xp, type, event_id;
int valid; int valid, bit;
struct arm_ccn_component *source; struct arm_ccn_component *source;
int i; int i;
...@@ -713,17 +713,18 @@ static int arm_ccn_pmu_event_init(struct perf_event *event) ...@@ -713,17 +713,18 @@ static int arm_ccn_pmu_event_init(struct perf_event *event)
/* Allocate an event source or a watchpoint */ /* Allocate an event source or a watchpoint */
if (type == CCN_TYPE_XP && event_id == CCN_EVENT_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); CCN_NUM_XP_WATCHPOINTS);
else 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); 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", dev_warn(ccn->dev, "No more event sources/watchpoints on node/XP %d!\n",
node_xp); node_xp);
clear_bit(hw->idx, ccn->dt.pmu_counters_mask); clear_bit(hw->idx, ccn->dt.pmu_counters_mask);
return -EAGAIN; return -EAGAIN;
} }
hw->config_base = bit;
ccn->dt.pmu_counters[hw->idx].event = event; ccn->dt.pmu_counters[hw->idx].event = event;
......
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