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_+frqevvq42...@mail.gmail.com
Reported-by: Linus Torvalds <torva...@linux-foundation.org>
Signed-off-by: Dan Williams <dan.j.willi...@intel.com>
---
 drivers/dax/kmem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
 
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-le...@lists.01.org

Reply via email to