Commit 38349665 authored by Andrzej Hajda's avatar Andrzej Hajda Committed by Arnaldo Carvalho de Melo

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/2038576Signed-off-by: default avatarAndrzej 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 1178bfd4
......@@ -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;
......
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