summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorAndrzej Hajda <a.hajda@samsung.com>2015-10-06 11:00:17 +0200
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-10-06 18:04:59 -0300
commit38349665388fb079fb2bc8c46db9446dd976802a (patch)
tree5b212fd3e5984d2faff65bf79bebc61f97f787c8 /tools/perf
parent1178bfd41f3ab6914eb6884875b776bc3032c9b5 (diff)
downloadblackbird-obmc-linux-38349665388fb079fb2bc8c46db9446dd976802a.tar.gz
blackbird-obmc-linux-38349665388fb079fb2bc8c46db9446dd976802a.zip
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>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/event.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index cb98b5af9e17..8b10621b415c 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -67,7 +67,8 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len,
char filename[PATH_MAX];
char bf[4096];
int fd;
- size_t size = 0, n;
+ size_t size = 0;
+ ssize_t n;
char *nl, *name, *tgids, *ppids;
*tgid = -1;
OpenPOWER on IntegriCloud