Javier Carrasco
5b042b7b3f
mfd: omap-usb-tll: Use struct_size to allocate tll
...
[ Upstream commit 40176714c818b0b6a2ca8213cdb7654fbd49b742 ]
Commit 16c2004d9e ("mfd: omap-usb-tll: Allocate driver data at once")
changed the memory allocation of 'tll' to consolidate it into a single
allocation, introducing an incorrect size calculation.
In particular, the allocation for the array of pointers was converted
into a single-pointer allocation.
The memory allocation used to occur in two steps:
tll = devm_kzalloc(dev, sizeof(struct usbtll_omap), GFP_KERNEL);
tll->ch_clk = devm_kzalloc(dev, sizeof(struct clk *) * tll->nch,
GFP_KERNEL);
And it turned that into the following allocation:
tll = devm_kzalloc(dev, sizeof(*tll) + sizeof(tll->ch_clk[nch]),
GFP_KERNEL);
sizeof(tll->ch_clk[nch]) returns the size of a single pointer instead of
the expected nch pointers.
This bug went unnoticed because the allocation size was small enough to
fit within the minimum size of a memory allocation for this particular
case [1].
The complete allocation can still be done at once with the struct_size
macro, which comes in handy for structures with a trailing flexible
array.
Fix the memory allocation to obtain the original size again.
Link: https://lore.kernel.org/all/202406261121.2FFD65647@keescook/ [1]
Fixes: 16c2004d9e ("mfd: omap-usb-tll: Allocate driver data at once")
Reviewed-by: Kees Cook <kees@kernel.org >
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com >
Fixes: commit 16c2004d9e ("mfd: omap-usb-tll: Allocate driver data at once")
Link: https://lore.kernel.org/r/20240626-omap-usb-tll-counted_by-v2-1-4bedf20d1b51@gmail.com
Signed-off-by: Lee Jones <lee@kernel.org >
Signed-off-by: Sasha Levin <sashal@kernel.org >
2024-08-03 08:53:54 +02:00
..
2023-06-15 09:19:37 +01:00
2023-06-15 09:19:37 +01:00
2023-06-15 09:19:37 +01:00
2023-06-15 09:19:37 +01:00
2019-06-19 17:09:55 +02:00
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:03 +01:00
2019-05-30 11:29:22 -07:00
2019-05-30 11:29:22 -07:00
2019-06-19 17:09:55 +02:00
2023-08-18 21:48:03 +01:00
2023-08-22 08:07:50 +01:00
2023-06-15 09:19:37 +01:00
2023-08-22 08:07:50 +01:00
2024-03-26 18:19:51 -04:00
2023-08-18 21:48:03 +01:00
2023-06-15 09:19:37 +01:00
2021-04-14 16:06:40 +01:00
2023-11-20 11:59:24 +01:00
2021-11-05 14:40:26 +00:00
2023-06-15 09:19:37 +01:00
2023-06-15 09:19:37 +01:00
2020-11-19 08:34:22 +00:00
2023-08-18 21:48:03 +01:00
2023-06-15 09:19:37 +01:00
2023-04-26 11:40:27 +01:00
2023-08-18 21:48:00 +01:00
2023-04-26 11:40:32 +01:00
2023-06-15 09:19:37 +01:00
2021-01-15 13:23:36 +00:00
2023-08-18 21:48:01 +01:00
2023-08-18 21:48:03 +01:00
2023-04-26 11:40:32 +01:00
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:03 +01:00
2023-08-17 12:06:11 +01:00
2024-01-25 15:35:49 -08:00
2024-03-26 18:19:55 -04:00
2023-08-17 12:06:11 +01:00
2023-08-18 21:48:01 +01:00
2023-08-18 21:48:02 +01:00
2023-08-18 21:48:02 +01:00
2023-08-18 21:48:02 +01:00
2023-08-18 21:48:02 +01:00
2023-08-18 21:48:02 +01:00
2019-11-11 08:45:03 +00:00
2023-06-15 09:19:37 +01:00
2023-04-26 11:40:32 +01:00
2023-08-18 21:48:03 +01:00
2019-06-19 17:09:55 +02:00
2023-04-26 11:40:32 +01:00
2023-04-26 11:40:31 +01:00
2023-08-18 21:48:03 +01:00
2023-08-18 21:48:03 +01:00
2020-11-19 08:34:21 +00:00
2023-06-15 09:19:37 +01:00
2019-05-14 08:13:26 +01:00
2023-06-15 09:19:37 +01:00
2021-08-05 14:19:59 +01:00
2022-07-19 10:54:41 +01:00
2023-11-20 11:59:24 +01:00
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:00 +01:00
2023-04-26 11:40:31 +01:00
2022-12-08 12:20:58 +00:00
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:03 +01:00
2023-08-22 08:07:51 +01:00
2021-10-05 08:56:08 +01:00
2020-04-24 11:18:44 +01:00
2021-08-11 16:00:53 +03:00
2022-07-19 10:54:42 +01:00
2023-06-15 09:19:37 +01:00
2023-06-15 09:19:37 +01:00
2023-06-15 09:19:37 +01:00
2020-08-13 07:50:05 +01:00
2023-06-15 09:19:39 +01:00
2023-11-28 17:19:44 +00:00
2024-01-25 15:35:49 -08:00
2021-12-29 13:17:01 +00:00
2023-06-15 09:19:36 +01:00
2023-06-15 09:19:36 +01:00
2023-06-15 09:19:36 +01:00
2021-08-12 11:39:39 +01:00
2023-08-22 08:07:50 +01:00
2023-08-18 21:48:03 +01:00
2021-11-05 14:40:27 +00:00
2024-02-05 20:14:31 +00:00
2023-02-22 08:25:51 +00:00
2023-06-15 09:19:37 +01:00
2023-06-15 09:19:37 +01:00
2020-07-01 14:54:29 +01:00
2023-08-22 08:07:51 +01:00
2023-08-18 21:48:03 +01:00
2023-06-15 09:19:37 +01:00
2022-09-28 16:09:50 +01:00
2023-06-15 09:19:37 +01:00
2023-08-22 08:07:51 +01:00
2022-09-28 16:17:39 +01:00
2021-09-07 08:44:07 +01:00
2022-12-07 13:28:07 +00:00
2023-08-18 21:48:03 +01:00
2023-08-18 21:48:03 +01:00
2019-07-15 20:18:40 -07:00
2024-08-03 08:53:53 +02:00
2023-08-18 21:48:03 +01:00
2023-08-18 21:48:03 +01:00
2023-06-15 09:19:37 +01:00
2018-10-23 08:58:34 +01:00
2023-08-18 21:48:03 +01:00
2018-10-23 08:58:34 +01:00
2023-08-18 21:48:03 +01:00
2023-08-22 08:07:51 +01:00
2023-08-22 08:07:51 +01:00
2023-08-18 21:48:03 +01:00
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:03 +01:00
2023-06-15 09:19:37 +01:00
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:03 +01:00
2022-03-07 14:00:27 +00:00
2023-08-22 08:07:52 +01:00
2022-12-07 13:28:10 +00:00
2021-11-05 14:40:26 +00:00
2021-07-21 11:53:42 +02:00
2022-12-07 13:28:11 +00:00
2023-06-15 09:19:37 +01:00
2023-06-15 09:19:37 +01:00
2023-11-20 11:59:24 +01:00
2022-12-08 13:15:46 +00:00
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:03 +01:00
2023-06-15 09:19:37 +01:00
2023-06-15 09:19:37 +01:00
2022-09-28 16:09:50 +01:00
2023-08-18 21:48:03 +01:00
2023-08-18 21:48:03 +01:00
2023-08-22 08:07:52 +01:00
2023-06-15 09:19:37 +01:00
2023-03-20 09:08:48 +00:00
2023-05-02 10:41:31 -07:00
2022-09-09 07:54:47 +01:00
2023-08-18 21:48:00 +01:00
2024-08-03 08:53:54 +02:00
2013-04-09 09:46:23 +02:00
2023-08-18 21:48:03 +01:00
2023-02-22 08:25:51 +00:00
2023-06-15 09:19:37 +01:00
2019-05-30 11:26:32 -07:00
2022-12-07 13:28:11 +00:00
2023-04-26 11:40:27 +01:00
2023-08-18 21:48:03 +01:00
2023-08-18 21:48:03 +01:00
2023-11-28 17:20:03 +00:00
2023-08-18 21:48:03 +01:00
2023-06-15 09:19:36 +01:00
2023-06-15 09:19:37 +01:00
2020-11-19 08:34:21 +00:00
2023-06-15 09:19:37 +01:00
2024-01-25 15:35:49 -08:00
2023-06-15 09:19:37 +01:00
2023-05-15 16:20:22 +01:00
2023-08-22 08:07:51 +01:00
2023-08-18 21:48:03 +01:00
2023-08-18 21:48:03 +01:00
2023-08-18 21:48:03 +01:00
2024-08-03 08:53:53 +02:00
2023-08-22 08:07:50 +01:00
2023-08-22 08:07:50 +01:00
2023-04-26 11:40:34 +01:00
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:03 +01:00
2023-06-15 09:19:37 +01:00
2023-08-22 08:07:52 +01:00
2023-04-26 11:40:34 +01:00
2023-08-18 21:48:03 +01:00
2023-04-26 11:40:26 +01:00
2023-04-26 11:40:26 +01:00
2023-06-15 09:19:37 +01:00
2019-06-05 17:36:37 +02:00
2023-06-15 09:19:37 +01:00
2021-08-16 13:45:34 +01:00
2023-06-15 09:19:37 +01:00
2022-12-07 13:28:11 +00:00
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:03 +01:00
2023-08-18 21:48:03 +01:00
2022-03-08 09:44:05 +00:00
2023-08-18 21:48:03 +01:00
2023-08-18 21:48:03 +01:00
2023-06-15 15:05:49 +01:00
2023-08-22 08:07:51 +01:00
2023-04-26 11:40:31 +01:00
2023-06-21 18:45:37 +01:00
2021-11-05 14:40:26 +00:00
2023-08-22 08:07:51 +01:00
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:03 +01:00
2021-06-02 10:51:19 +01:00
2024-03-26 18:19:51 -04:00
2023-08-22 08:07:52 +01:00
2023-08-18 21:48:03 +01:00
2023-08-18 21:48:03 +01:00
2022-12-07 13:28:13 +00:00
2019-05-30 11:29:19 -07:00
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:03 +01:00
2023-06-15 09:19:37 +01:00
2024-01-25 15:35:49 -08:00
2023-06-26 16:38:30 +01:00
2023-06-15 09:19:38 +01:00
2023-07-03 10:55:04 -07:00
2023-08-18 21:43:02 +01:00
2023-08-18 21:48:03 +01:00
2023-08-18 21:48:03 +01:00
2023-08-18 21:48:03 +01:00
2023-06-15 09:19:38 +01:00
2023-06-15 09:19:37 +01:00
2020-11-19 08:34:22 +00:00
2022-06-10 14:51:36 +02:00
2023-06-15 09:19:37 +01:00
2022-06-10 14:51:36 +02:00
2023-04-26 11:40:28 +01:00
2023-04-26 11:40:30 +01:00
2022-09-28 16:17:41 +01:00
2023-02-22 08:25:52 +00:00
2022-04-28 17:24:10 +01:00
2023-08-18 21:48:03 +01:00
2023-06-15 09:19:37 +01:00
2022-04-28 17:24:40 +01:00
2021-06-15 13:02:01 +01:00
2022-12-07 13:28:11 +00:00
2019-06-19 17:09:55 +02:00
2022-11-14 10:01:39 +01:00
2019-05-30 11:26:32 -07:00
2019-05-30 11:26:35 -07:00
2023-06-15 09:19:38 +01:00
2023-06-15 09:19:37 +01:00
2023-01-25 09:34:20 +01:00
2021-02-08 13:54:40 +00:00
2023-08-18 21:48:03 +01:00
2023-08-22 08:07:52 +01:00
2019-05-30 11:26:32 -07:00
2021-06-15 13:01:45 +01:00
2023-08-22 08:07:52 +01:00
2023-08-18 21:48:02 +01:00
2023-08-18 21:48:02 +01:00
2020-07-06 08:31:57 +01:00
2019-05-30 11:26:32 -07:00
2023-06-15 09:19:37 +01:00
2019-05-30 11:26:32 -07:00
2019-05-30 11:26:32 -07:00
2023-06-15 09:19:37 +01:00
2023-08-22 08:07:52 +01:00
2021-08-05 12:41:06 +01:00
2023-08-18 21:48:02 +01:00
2019-05-30 11:26:32 -07:00
2023-08-18 21:48:03 +01:00
2023-08-18 21:48:03 +01:00