tools: bpf_jit_disasm: check for klogctl failure
authorColin Ian King <colin.king@canonical.com>
Thu, 5 May 2016 22:39:33 +0000 (23:39 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 9 May 2016 03:32:59 +0000 (23:32 -0400)
klogctl can fail and return -ve len, so check for this and
return NULL to avoid passing a (size_t)-1 to malloc.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/net/bpf_jit_disasm.c

index 5b32413409459ce165e2f56990dbc0f52aa8bd31..544b05a53b7057bbe9092e31f600065d47e3b24e 100644 (file)
@@ -98,6 +98,9 @@ static char *get_klog_buff(unsigned int *klen)
        char *buff;
 
        len = klogctl(CMD_ACTION_SIZE_BUFFER, NULL, 0);
+       if (len < 0)
+               return NULL;
+
        buff = malloc(len);
        if (!buff)
                return NULL;