Re: DMA: atmel_serial: Opening and closing the serial device repeatedly causes kmalloc-32 slab leak

From: Alexandre Belloni
Date: Tue Nov 27 2018 - 04:58:59 EST


Hello Richard,

On 27/11/2018 10:51:13+0100, richard.genoud@xxxxxxxxx wrote:
> Hi all,
>
> I reproduced the memory leak on my board (at91sam9g35-cm) with a 4.20-rc3.
>
> It triggered an OOM after a couple of hours running a code like this:
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <unistd.h>
>
>
> int main(int argc, char **argv)
> {
> int fd;
> do {
> fd = open("/dev/ttyS1", O_RDONLY);
> close(fd);
> } while (true);
> return 0;
> }
>
> As Mario pointed out, this only happens when atmel,use-dma-{r,t}x are
> used in the device-tree.
>
> Adding:
> CONFIG_DEBUG_SLAB=y
> CONFIG_DEBUG_SLAB_LEAK=y
> Doesn't show anything suspect in /proc/slab_allocators
>
> From what I found until now, it's something done in :
> dma_request_slave_channel();
> that leaks kmalloc-32
> Mabe I missed something, but it seems that everything DMA related is
> deallocated in atmel_release_{tx,rx}_dma().
>
> Is this ringing a bell ?
>

Yes, this is known issue and it has yet to be worked on.

--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com