tools: bpf_jit_disasm: check for klogctl failure
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>
This commit is contained in:
parent
810810ffb2
commit
25a54342fd
|
@ -98,6 +98,9 @@ static char *get_klog_buff(unsigned int *klen)
|
||||||
char *buff;
|
char *buff;
|
||||||
|
|
||||||
len = klogctl(CMD_ACTION_SIZE_BUFFER, NULL, 0);
|
len = klogctl(CMD_ACTION_SIZE_BUFFER, NULL, 0);
|
||||||
|
if (len < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
buff = malloc(len);
|
buff = malloc(len);
|
||||||
if (!buff)
|
if (!buff)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user