* [PATCH] bus: arm-ccn: Fix error handling at event allocation
@ 2014-07-31 15:16 Pawel Moll
2014-08-01 3:47 ` Olof Johansson
0 siblings, 1 reply; 2+ messages in thread
From: Pawel Moll @ 2014-07-31 15:16 UTC (permalink / raw)
To: linux-arm-kernel
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>
---
Dan discovered the problem using his static checker. Thanks, Dan!
Arnd, would you pick up the patch as it is or do you want me
to send a pull request for a "ccn/fixes" branch?
drivers/bus/arm-ccn.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/bus/arm-ccn.c b/drivers/bus/arm-ccn.c
index 4f86bbb..3266f8f 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;
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] bus: arm-ccn: Fix error handling at event allocation
2014-07-31 15:16 [PATCH] bus: arm-ccn: Fix error handling at event allocation Pawel Moll
@ 2014-08-01 3:47 ` Olof Johansson
0 siblings, 0 replies; 2+ messages in thread
From: Olof Johansson @ 2014-08-01 3:47 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Jul 31, 2014 at 04:16:37PM +0100, Pawel Moll wrote:
> 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>
> ---
>
> Dan discovered the problem using his static checker. Thanks, Dan!
>
> Arnd, would you pick up the patch as it is or do you want me
> to send a pull request for a "ccn/fixes" branch?
I've started to prefer applying patches for cases like these, single-patch
pull requests are actually more work than doing that.
So: applied on top of next/drivers, where the CCN driver was merged
as well.
Thanks!
-Olof
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-01 3:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-31 15:16 [PATCH] bus: arm-ccn: Fix error handling at event allocation Pawel Moll
2014-08-01 3:47 ` Olof Johansson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).