On Fri, Apr 5, 2019 at 7:54 AM Anshuman Khandual <anshuman.khandual@xxxxxxx> wrote: [..] > > Given that what seems to ultimately get corrupted is the memory pointed to by pgmap here, how is *that* being allocated? > > struct dev_pagemap *pgmap; > > pgmap = devm_kzalloc(dev, sizeof(struct dev_pagemap), GFP_KERNEL); > > Is it problematic to use dev_kzalloc here instead of generic kmalloc/kzalloc > functions ? On this specific question, no. devm_kzalloc() is how the pmem and device-dax drivers allocate the pgmap passed to devm_memremap_pages(). The unwind order of the devres resources ensures that the devm_memremap_pages() devres actions occur before the release of the pgmap allocation.