Javier Carrasco
6b4cf1c885
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:49:15 +02:00
..
2019-06-19 17:09:55 +02:00
2022-08-16 12:46:26 +02:00
2022-08-16 12:46:26 +02:00
2022-08-16 12:46:26 +02:00
2019-06-19 17:09:55 +02:00
2020-03-30 07:35:28 +01:00
2022-03-23 14:51:51 +00: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
2022-08-16 12:46:26 +02:00
2019-05-30 11:26:32 -07:00
2019-05-30 11:25:18 -07:00
2021-11-05 14:40:26 +00:00
2024-03-26 18:20:50 -04:00
2023-03-11 13:55:32 +01:00
2022-08-16 12:46:26 +02:00
2021-04-14 16:06:40 +01:00
2023-11-20 11:52:08 +01:00
2021-11-05 14:40:26 +00:00
2019-06-05 17:37:04 +02:00
2021-06-02 10:51:19 +01:00
2022-07-19 10:54:38 +01:00
2020-11-19 08:34:22 +00:00
2021-03-10 11:10:23 +00:00
2021-04-14 16:06:15 +01:00
2022-03-23 14:51:38 +00:00
2020-01-07 10:08:58 +00:00
2022-08-03 11:03:03 +02:00
2022-08-16 12:46:26 +02:00
2021-01-15 13:23:36 +00:00
2022-12-31 13:32:52 +01:00
2020-11-27 08:00:47 +00:00
2022-07-04 11:42:20 +01:00
2021-01-14 13:05:55 +00:00
2022-08-06 10:25:16 -07:00
2020-01-24 07:33:58 +00:00
2019-06-19 17:09:55 +02:00
2019-07-02 12:11:31 +01:00
2019-07-02 12:11:31 +01:00
2019-07-02 12:11:31 +01:00
2019-07-02 12:11:31 +01:00
2019-11-11 08:45:03 +00:00
2022-08-16 12:46:26 +02:00
2019-05-30 11:26:32 -07:00
2022-08-16 12:46:26 +02:00
2019-06-19 17:09:55 +02:00
2022-02-09 13:00:45 +00:00
2021-06-02 10:51:19 +01:00
2022-08-16 12:46:26 +02:00
2022-10-07 11:24:20 -07:00
2020-11-19 08:34:21 +00:00
2021-11-05 14:40:05 +00:00
2019-05-14 08:13:26 +01:00
2022-08-16 12:46:26 +02:00
2022-05-23 14:52:45 +01:00
2021-08-05 14:19:59 +01:00
2022-07-19 10:54:41 +01:00
2023-11-20 11:52:08 +01:00
2022-08-16 12:46:26 +02:00
2022-08-16 12:46:26 +02:00
2022-03-08 09:44:06 +00:00
2022-03-21 18:33:57 -07:00
2022-09-28 16:17:39 +01:00
2022-08-16 12:46:26 +02:00
2022-04-26 15:10:29 +01:00
2020-08-13 07:50:59 +01:00
2021-10-05 08:56:08 +01:00
2022-09-28 16:17:41 +01:00
2019-06-05 17:37:17 +02: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
2022-09-28 16:17:41 +01:00
2023-05-24 17:32:42 +01:00
2022-10-07 11:24:20 -07:00
2020-08-13 07:50:05 +01:00
2023-07-19 16:21:56 +02:00
2023-11-28 17:07:01 +00:00
2024-01-25 15:27:45 -08:00
2021-12-29 13:17:01 +00:00
2022-09-28 16:17:40 +01:00
2021-08-12 11:39:39 +01:00
2022-04-26 15:12:22 +01:00
2022-08-16 12:46:26 +02:00
2021-11-05 14:40:27 +00:00
2024-02-05 20:12:58 +00:00
2021-06-15 13:13:54 +01:00
2020-09-30 16:24:50 +01:00
2022-08-16 12:46:26 +02:00
2020-07-01 14:54:29 +01:00
2019-02-07 10:44:00 +00:00
2022-06-10 14:51:35 +02:00
2019-06-19 17:09:55 +02:00
2022-09-28 16:09:50 +01:00
2022-10-07 11:24:20 -07:00
2021-06-02 10:50:00 +01:00
2022-09-28 16:17:39 +01:00
2021-09-07 08:44:07 +01:00
2020-11-19 08:34:22 +00:00
2022-08-16 12:46:26 +02:00
2022-02-09 13:00:45 +00:00
2019-07-15 20:18:40 -07:00
2024-08-03 08:49:15 +02:00
2022-08-16 12:46:26 +02:00
2020-11-19 08:34:21 +00:00
2022-08-16 12:46:26 +02:00
2018-10-23 08:58:34 +01:00
2021-06-02 10:51:17 +01:00
2018-10-23 08:58:34 +01:00
2021-06-02 10:51:17 +01:00
2022-08-16 12:46:26 +02:00
2022-07-19 10:54:39 +01:00
2020-11-27 08:01:46 +00:00
2022-03-07 13:54:24 +00:00
2022-08-16 12:46:26 +02:00
2022-07-19 10:54:38 +01:00
2019-08-12 08:54:05 +01:00
2022-03-07 14:00:27 +00:00
2022-08-16 12:46:26 +02:00
2022-02-09 13:00:45 +00:00
2021-11-05 14:40:26 +00:00
2021-07-21 11:53:42 +02:00
2021-02-08 13:54:10 +00:00
2022-08-16 12:46:26 +02:00
2019-05-30 11:26:32 -07:00
2023-11-20 11:52:08 +01:00
2021-11-05 14:40:25 +00:00
2020-05-26 10:41:40 +01:00
2022-07-19 10:54:39 +01:00
2023-01-04 11:29:01 +01:00
2022-09-28 16:09:50 +01:00
2022-09-28 16:09:50 +01:00
2022-07-19 10:54:41 +01:00
2022-07-19 10:54:41 +01:00
2020-08-23 17:36:59 -05:00
2022-08-16 12:46:26 +02:00
2022-09-09 07:54:47 +01:00
2023-05-11 23:03:38 +09:00
2022-09-09 07:54:47 +01:00
2021-06-02 10:50:03 +01:00
2024-08-03 08:49:15 +02:00
2022-08-16 12:46:26 +02:00
2023-03-10 09:33:28 +01:00
2022-08-16 12:46:26 +02:00
2019-05-30 11:26:32 -07:00
2019-05-30 11:26:32 -07:00
2022-12-31 13:33:12 +01:00
2021-11-05 14:40:25 +00:00
2023-07-23 13:49:37 +02:00
2023-11-28 17:07:12 +00:00
2020-08-23 17:36:59 -05:00
2019-05-30 11:29:52 -07:00
2019-05-30 11:29:52 -07:00
2020-11-19 08:34:21 +00:00
2022-08-16 12:46:26 +02:00
2022-10-07 11:24:20 -07:00
2022-08-16 12:46:26 +02:00
2021-04-14 10:17:53 +01:00
2022-03-23 14:51:51 +00:00
2021-04-14 10:19:08 +01:00
2024-08-03 08:49:15 +02:00
2022-08-16 12:46:26 +02:00
2022-02-09 13:00:45 +00:00
2021-07-13 12:20:44 +01:00
2022-08-16 12:46:26 +02:00
2023-07-19 16:21:54 +02:00
2022-09-28 16:09:50 +01:00
2021-06-02 10:51:18 +01:00
2021-11-05 14:40:06 +00:00
2021-06-02 10:50:04 +01:00
2022-08-16 12:46:26 +02:00
2019-06-05 17:36:37 +02:00
2022-02-08 09:27:22 +00:00
2021-08-16 13:45:34 +01:00
2020-07-01 10:40:11 +01:00
2022-09-28 16:17:41 +01:00
2022-04-27 10:33:11 +01:00
2019-06-05 17:36:37 +02:00
2022-03-08 09:44:05 +00:00
2020-06-18 11:19:49 +01:00
2021-04-14 16:06:26 +01:00
2023-07-19 16:21:57 +02:00
2022-08-16 12:46:26 +02:00
2022-02-09 13:00:45 +00:00
2023-07-19 16:21:58 +02:00
2021-11-05 14:40:26 +00:00
2024-05-25 16:21:30 +02:00
2019-05-30 11:29:22 -07:00
2020-11-27 08:02:27 +00:00
2021-06-02 10:51:19 +01:00
2024-03-26 18:20:50 -04:00
2022-07-19 10:54:38 +01:00
2022-08-16 12:46:26 +02:00
2020-11-19 08:34:21 +00:00
2022-07-19 10:54:40 +01:00
2021-11-05 14:40:02 +00:00
2019-07-09 08:59:39 -07:00
2021-06-15 13:02:18 +01:00
2019-05-30 11:29:19 -07:00
2019-06-19 17:09:55 +02:00
2022-08-16 12:46:26 +02:00
2022-08-16 12:46:26 +02:00
2022-08-16 12:46:26 +02:00
2022-08-16 12:46:26 +02:00
2020-11-19 08:34:21 +00:00
2022-08-16 12:46:26 +02:00
2022-06-10 14:51:36 +02:00
2021-12-29 13:36:16 +00:00
2020-11-19 08:34:22 +00:00
2022-06-10 14:51:36 +02:00
2022-08-16 12:46:26 +02:00
2022-06-10 14:51:36 +02:00
2023-05-11 23:03:38 +09:00
2019-06-05 17:37:07 +02:00
2022-09-28 16:17:41 +01:00
2022-04-28 17:24:10 +01:00
2022-08-16 12:46:26 +02:00
2022-10-07 11:24:20 -07:00
2022-04-28 17:24:40 +01:00
2021-06-15 13:02:01 +01:00
2019-05-30 11:29:19 -07:00
2019-06-19 17:09:55 +02:00
2022-07-19 09:56:51 +02:00
2020-05-13 12:42:46 -05:00
2019-05-30 11:26:32 -07:00
2019-05-30 11:26:35 -07:00
2023-07-19 16:21:56 +02:00
2019-06-05 17:37:07 +02:00
2019-05-30 11:26:32 -07:00
2021-02-08 13:54:40 +00:00
2021-06-15 12:53:38 +01:00
2019-05-30 11:26:32 -07:00
2019-05-30 11:26:32 -07:00
2021-06-15 13:01:45 +01:00
2019-05-30 11:26:32 -07:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2020-07-06 08:31:57 +01:00
2019-05-30 11:26:32 -07:00
2019-05-30 11:26:32 -07:00
2019-05-30 11:26:32 -07:00
2019-05-30 11:26:32 -07:00
2020-07-06 08:31:56 +01:00
2022-08-16 12:46:26 +02:00
2021-08-05 12:41:06 +01:00
2019-05-30 11:26:32 -07:00
2019-05-30 11:26:32 -07:00
2019-06-19 17:09:55 +02:00
2019-11-11 08:45:02 +00:00