contigmem: cleanup properly when load fails
authorJim Harris <james.r.harris@intel.com>
Mon, 9 Mar 2020 10:00:25 +0000 (03:00 -0700)
committerDavid Marchand <david.marchand@redhat.com>
Thu, 19 Mar 2020 14:42:00 +0000 (15:42 +0100)
commit3df951337441cc6b7bb99996e0acf185d4aa52c5
treeb11f6a9e1af80f8fe8c382dbb21e616b574a9605
parent8d4659e70fc081ab220e44552af194900d720d2e
contigmem: cleanup properly when load fails

If contigmem is not able to allocate all of the
requested buffers, it frees whatever buffers were
able to be allocated up until that point.

But the pointers are not set to NULL in that case.
After the load fails, the FreeBSD kernel will
immediately call the contigmem unload handler, which
tries to free the buffers again since the pointers
were not set to NULL.

It's not clear that we should just rely on the unload
handler getting called after load failure. So let's
keep the existing cleanup code in the load handler,
but explicitly set the pointers to NULL after freeing
them.

Fixes: 5f51eca22489 ("contigmem: free allocated memory on error")
Cc: stable@dpdk.org
Signed-off-by: Jim Harris <james.r.harris@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
kernel/freebsd/contigmem/contigmem.c