aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2019-07-25 15:05:50 -0400
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>2019-07-30 07:12:51 -0400
commitc03f282e506f1e873ef9b270cf245509d68dd53b (patch)
tree3f74436f9ee685e12c4df0291a9c7e9447c5096e
parentaaed5c9c2a146640170e0fbc84ca97e352c065ce (diff)
platform/x86: i2c-multi-instantiate: Use struct_size() helper
One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--drivers/platform/x86/i2c-multi-instantiate.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/platform/x86/i2c-multi-instantiate.c b/drivers/platform/x86/i2c-multi-instantiate.c
index 197d8a192721..61fe341a85aa 100644
--- a/drivers/platform/x86/i2c-multi-instantiate.c
+++ b/drivers/platform/x86/i2c-multi-instantiate.c
@@ -81,9 +81,7 @@ static int i2c_multi_inst_probe(struct platform_device *pdev)
81 if (ret < 0) 81 if (ret < 0)
82 return ret; 82 return ret;
83 83
84 multi = devm_kmalloc(dev, 84 multi = devm_kmalloc(dev, struct_size(multi, clients, ret), GFP_KERNEL);
85 offsetof(struct i2c_multi_inst_data, clients[ret]),
86 GFP_KERNEL);
87 if (!multi) 85 if (!multi)
88 return -ENOMEM; 86 return -ENOMEM;
89 87