Fix null pointer deference in nest_epollfd
PATCH 1/1 Fix null pointer deference in nest_epollfd
Add a NULL check for worker before dereferencing.
--- tools/perf/bench/epoll-wait.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/bench/epoll-wait.c +3 -0
@@ -239,6 +239,9 @@ static void *workerfn(void *arg)static void nest_epollfd (struct worker *w) { +if (!w) +return ; +unsigned int i;struct epoll_event ev;int efd = multiq ? w->epollfd : epollfd;
Signature · 1 line
2.17.1
Namhyung Kim
maintainerHello,
Quoted 2 lines · Gaurav Singh
Add a NULL check for worker before dereferencing.
Did you actually see a segfault due to this? It seems it's called with NULL only if multiq is false so there should not be a NULL dereference.
Quoted 11 lines
Signed-off-by Gaurav Singh <[email protected]>--- tools/perf/bench/epoll-wait.c | 3 +++ 1 file changed, 3 insertions(+)tools/perf/bench/epoll-wait.c +0
-0
tools/perf/bench/epoll-wait.c static void *workerfn(void *arg) · line 247
Quoted 9 lines
tools/perf/bench/epoll-wait.c +3
-0@@ -239,6 +239,9 @@ static void *workerfn(void *arg)static void nest_epollfd (struct worker *w) { +if (!w) +return ; +unsigned int i;struct epoll_event ev;int efd = multiq ? w->epollfd : epollfd;
Maybe it's more intuitive to check w instead of multiq here.
Thanks
Namhyung
Quoted 3 lines
--
2.17.1
A message that is not in the archive (sent off-list or not yet received): CAFAFadA3rRQxw9nyGnhn7kshRfQ_2AN+d-eCwHF-HJ_bYfYVog@mail.gmail.com
Namhyung Kim
maintainerQuoted 2 lines · gaurav singh
multiqu is a static bool which is never assigned and nested is a static int (=0)
It's set by command line option (-m).
Thanks
Namhyung
Quoted 6 lines
and only assigned in
nest_epollfd(). Hence,if (nested) nest_epollfd(NULL);probably never gets executed.