]> Git Repo - linux.git/commitdiff
device-dax/kmem: use struct_size()
authorDan Williams <[email protected]>
Tue, 15 Dec 2020 03:04:43 +0000 (19:04 -0800)
committerLinus Torvalds <[email protected]>
Tue, 15 Dec 2020 20:13:38 +0000 (12:13 -0800)
Linus notes the kernel has had a nice helper for the 'size of struct with
variable array member at the end' operation for a couple years now, use
it.

Link: http://lore.kernel.org/r/CAHk-=wgNTLbvAD8mNTvh+GQyapNWeX20PXhU_+frqEvVq4298w@mail.gmail.com
Link: https://lkml.kernel.org/r/160288261564.3242821.6055291930923876456.stgit@dwillia2-desk3.amr.corp.intel.com
Signed-off-by: Dan Williams <[email protected]>
Reported-by: Linus Torvalds <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
drivers/dax/kmem.c

index b4368c5b6a0cc9df10cff1a2b6145e0a72bfdced..403ec42472d1d9ff9480e2db0b3a12ee03fc4004 100644 (file)
@@ -61,7 +61,7 @@ static int dev_dax_kmem_probe(struct dev_dax *dev_dax)
                return -EINVAL;
        }
 
-       data = kzalloc(sizeof(*data) + sizeof(struct resource *) * dev_dax->nr_range, GFP_KERNEL);
+       data = kzalloc(struct_size(data, res, dev_dax->nr_range), GFP_KERNEL);
        if (!data)
                return -ENOMEM;
 
This page took 0.049689 seconds and 4 git commands to generate.