diff options
author | Dan Williams <dan.j.williams@intel.com> | 2020-12-15 04:04:43 +0100 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-12-15 21:13:38 +0100 |
commit | 7d18dd75a8afc072aabc77f2a9c3df94cdc53f33 (patch) | |
tree | d5842f652bcb81fcace42995a553e4e308510c60 /drivers/dax | |
parent | mm/slub: let number of online CPUs determine the slub page order (diff) | |
download | linux-7d18dd75a8afc072aabc77f2a9c3df94cdc53f33.tar.xz linux-7d18dd75a8afc072aabc77f2a9c3df94cdc53f33.zip |
device-dax/kmem: use struct_size()
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 <dan.j.williams@intel.com>
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/dax')
-rw-r--r-- | drivers/dax/kmem.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/dax/kmem.c b/drivers/dax/kmem.c index b4368c5b6a0c..403ec42472d1 100644 --- a/drivers/dax/kmem.c +++ b/drivers/dax/kmem.c @@ -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; |