[dpdk-dev] [dpdk-stable] [PATCH] eal: fix unitialized data warning

Stephen Hemminger stephen at networkplumber.org
Fri Nov 29 18:02:27 CET 2019


On Fri, 29 Nov 2019 09:25:15 +0100
David Marchand <david.marchand at redhat.com> wrote:

> On Wed, Nov 27, 2019 at 11:32 PM Stephen Hemminger
> <stephen at networkplumber.org> wrote:
> >
> > Valgrind reports that eal interrupt thread is calling epoll_ctl
> > with uninitialized data.  Trivial to fix by initializing it.
> >
> > Fixes: af75078fece3 ("first public release")
> > Cc: stable at dpdk.org
> > Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> > ---
> >  lib/librte_eal/linux/eal/eal_interrupts.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/librte_eal/linux/eal/eal_interrupts.c b/lib/librte_eal/linux/eal/eal_interrupts.c
> > index 1955324d3045..2cd537ba4492 100644
> > --- a/lib/librte_eal/linux/eal/eal_interrupts.c
> > +++ b/lib/librte_eal/linux/eal/eal_interrupts.c
> > @@ -1045,7 +1045,7 @@ eal_intr_handle_interrupts(int pfd, unsigned totalfds)
> >  static __attribute__((noreturn)) void *
> >  eal_intr_thread_main(__rte_unused void *arg)
> >  {
> > -       struct epoll_event ev;
> > +       struct epoll_event ev = { };
> >
> >         /* host thread, never break out */
> >         for (;;) {  
> 
> typedef union epoll_data
> {
>   void *ptr;
>   int fd;
>   uint32_t u32;
>   uint64_t u64;
> } epoll_data_t;
> 
> struct epoll_event
> {
>   uint32_t events;      /* Epoll events */
>   epoll_data_t data;    /* User data variable */
> } __EPOLL_PACKED;
> 
> 
> static __attribute__((noreturn)) void *
> eal_intr_thread_main(__rte_unused void *arg)
> {
>         struct epoll_event ev;
> [...]
>                         ev.events = EPOLLIN | EPOLLPRI | EPOLLRDHUP | EPOLLHUP;
>                         ev.data.fd = src->intr_handle.fd;
> [...]
>                         if (epoll_ctl(pfd, EPOLL_CTL_ADD,
>                                         src->intr_handle.fd, &ev) < 0){
> 
> So the uninitialised part is because we only set an int in the union.
> False positive from valgrind, but the fix is quite simple.
> 
> Acked-by: David Marchand <david.marchand at redhat.com>

Agreed it is a false positive because the kernel is not going to care about
the unused bits in the union. But I wanted to make the application
run clean under valgrind. Otherwise, it is hard to find the real warnings
in surrounding noise.


More information about the dev mailing list