perf tools: Fix handling read result using a signed variable
authorAndrzej Hajda <a.hajda@samsung.com>
Tue, 6 Oct 2015 09:00:17 +0000 (11:00 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 6 Oct 2015 21:04:59 +0000 (18:04 -0300)
commit38349665388fb079fb2bc8c46db9446dd976802a
tree5b212fd3e5984d2faff65bf79bebc61f97f787c8
parent1178bfd41f3ab6914eb6884875b776bc3032c9b5
perf tools: Fix handling read result using a signed variable

The function can return negative value, assigning it to unsigned
variable can cause memory corruption.

The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: kernel-janitors@vger.kernel.org
Link: http://lkml.kernel.org/r/1444122017-16856-1-git-send-email-a.hajda@samsung.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/event.c