The patch titled Subject: device-dax: use struct_size() has been added to the -mm tree. Its filename is device-dax-use-struct_size.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/device-dax-use-struct_size.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/device-dax-use-struct_size.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Joao Martins <joao.m.martins@xxxxxxxxxx> Subject: device-dax: use struct_size() Use the struct_size() helper for the size of a struct with variable array member at the end, rather than manually calculating it. Link: https://lkml.kernel.org/r/20211202204422.26777-7-joao.m.martins@xxxxxxxxxx Suggested-by: Dan Williams <dan.j.williams@xxxxxxxxx> Signed-off-by: Joao Martins <joao.m.martins@xxxxxxxxxx> Cc: Christoph Hellwig <hch@xxxxxx> Cc: Dave Jiang <dave.jiang@xxxxxxxxx> Cc: Jane Chu <jane.chu@xxxxxxxxxx> Cc: Jason Gunthorpe <jgg@xxxxxxxxxx> Cc: Jason Gunthorpe <jgg@xxxxxxxx> Cc: John Hubbard <jhubbard@xxxxxxxxxx> Cc: Jonathan Corbet <corbet@xxxxxxx> Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Cc: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Cc: Muchun Song <songmuchun@xxxxxxxxxxxxx> Cc: Naoya Horiguchi <naoya.horiguchi@xxxxxxx> Cc: Vishal Verma <vishal.l.verma@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/dax/device.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/dax/device.c~device-dax-use-struct_size +++ a/drivers/dax/device.c @@ -404,8 +404,9 @@ int dev_dax_probe(struct dev_dax *dev_da return -EINVAL; if (!pgmap) { - pgmap = devm_kzalloc(dev, sizeof(*pgmap) + sizeof(struct range) - * (dev_dax->nr_range - 1), GFP_KERNEL); + pgmap = devm_kzalloc(dev, + struct_size(pgmap, ranges, dev_dax->nr_range - 1), + GFP_KERNEL); if (!pgmap) return -ENOMEM; pgmap->nr_range = dev_dax->nr_range; _ Patches currently in -mm which might be from joao.m.martins@xxxxxxxxxx are mm-page_alloc-split-prep_compound_page-into-head-and-tail-subparts.patch mm-page_alloc-refactor-memmap_init_zone_device-page-init.patch mm-memremap-add-zone_device-support-for-compound-pages.patch device-dax-use-align-for-determining-pgoff.patch device-dax-use-struct_size.patch device-dax-ensure-dev_dax-pgmap-is-valid-for-dynamic-devices.patch device-dax-factor-out-page-mapping-initialization.patch device-dax-set-mapping-prior-to-vmf_insert_pfn_pmdpud.patch device-dax-remove-pfn-from-__dev_dax_ptepmdpud_fault.patch device-dax-compound-devmap-support.patch