Javier Carrasco
fecdddd852
mfd: omap-usb-tll: Use struct_size to allocate tll
...
[ Upstream commit 40176714c8 ]
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 09:00:03 +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
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:03 +01:00
2024-01-10 11:25:56 +00:00
2024-02-23 14:58:03 +00: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-02-23 16:02:16 +00:00
2023-08-18 21:48:03 +01:00
2023-11-01 10:02:12 +00:00
2023-11-01 10:02:16 +00:00
2024-02-23 14:58:03 +00:00
2024-02-23 14:58:03 +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-11-01 10:02:11 +00:00
2023-04-26 11:40:32 +01:00
2024-03-28 09:50:59 +00:00
2024-03-28 09:50:59 +00:00
2024-06-14 08:43:39 +01:00
2024-02-23 14:58:03 +00:00
2023-04-26 11:40:32 +01:00
2024-02-23 14:58:03 +00:00
2024-02-23 17:14:13 +00:00
2024-02-23 14:58:02 +00:00
2024-02-23 14:58:02 +00:00
2024-05-10 15:39:17 +01:00
2024-02-23 14:58:01 +00: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
2023-06-15 09:19:37 +01:00
2024-02-23 14:58:04 +00:00
2023-08-18 21:48:03 +01:00
2023-04-26 11:40:32 +01:00
2024-02-23 14:58:04 +00:00
2023-08-18 21:48:03 +01:00
2024-02-23 14:58:04 +00:00
2024-02-23 14:58:04 +00:00
2024-02-23 14:58:04 +00:00
2023-11-01 10:02:14 +00:00
2023-11-01 10:02:13 +00:00
2023-06-15 09:19:37 +01:00
2023-12-07 13:50:26 +00:00
2023-04-26 11:40:31 +01:00
2023-12-07 13:50:26 +00:00
2023-06-15 09:19:37 +01:00
2023-12-07 13:50:26 +00:00
2023-11-01 10:02:17 +00: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
2023-12-07 13:50:29 +00:00
2024-05-10 15:39:15 +01:00
2024-02-23 14:58:00 +00:00
2024-02-23 14:58:00 +00:00
2023-06-15 09:19:36 +01:00
2024-05-10 15:39:16 +01:00
2024-05-10 15:39:16 +01:00
2023-08-22 08:07:50 +01:00
2023-11-01 10:02:12 +00:00
2024-05-10 15:39:16 +01:00
2024-05-10 15:39:17 +01:00
2024-02-23 14:58:04 +00:00
2023-06-15 09:19:37 +01:00
2024-02-23 14:58:04 +00: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-11-01 10:02:17 +00:00
2024-02-23 14:58:00 +00:00
2022-12-07 13:28:07 +00:00
2023-11-01 10:02:12 +00:00
2023-08-18 21:48:03 +01:00
2024-08-03 09:00:03 +02:00
2023-11-01 10:02:15 +00:00
2023-08-18 21:48:03 +01:00
2023-06-15 09:19:37 +01:00
2023-11-01 10:02:09 +00:00
2023-11-01 10:02:13 +00:00
2023-11-01 10:02:17 +00:00
2023-11-01 10:02:12 +00:00
2023-11-01 10:02:15 +00:00
2023-06-15 09:19:37 +01:00
2023-11-01 10:02:15 +00: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
2024-02-23 15:53:29 +00:00
2023-08-22 08:07:52 +01:00
2023-11-01 10:02:16 +00:00
2024-02-23 14:58:03 +00:00
2023-12-07 13:50:27 +00:00
2023-06-15 09:19:37 +01:00
2023-06-15 09:19:37 +01:00
2024-02-23 16:27:13 +00:00
2023-11-01 10:02:16 +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
2024-02-29 17:44:49 +00:00
2023-08-18 21:48:03 +01:00
2023-12-07 13:50:27 +00:00
2023-06-15 09:19:37 +01:00
2023-03-20 09:08:48 +00:00
2024-05-10 15:39:16 +01:00
2022-09-09 07:54:47 +01:00
2024-02-23 14:58:00 +00:00
2024-08-03 09:00:03 +02:00
2023-11-01 10:02:10 +00:00
2023-12-07 13:50:27 +00:00
2023-06-15 09:19:37 +01:00
2022-12-07 13:28:11 +00:00
2023-11-01 10:02:17 +00:00
2023-12-07 13:50:27 +00:00
2023-08-18 21:48:03 +01:00
2023-12-07 13:50:28 +00:00
2024-03-21 12:44:10 -07:00
2023-06-15 09:19:36 +01:00
2024-02-23 14:58:05 +00:00
2023-06-15 09:19:37 +01:00
2024-05-03 09:15:30 +01:00
2024-05-03 09:15:30 +01:00
2024-02-23 14:58:04 +00:00
2024-02-23 14:58:04 +00:00
2024-02-23 14:58:04 +00:00
2024-02-23 14:58:04 +00:00
2024-05-10 15:39:16 +01:00
2024-08-03 09:00:03 +02:00
2024-05-10 15:39:18 +01:00
2024-05-10 15:39:18 +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
2024-02-23 14:58:05 +00:00
2023-06-15 09:19:37 +01:00
2023-06-15 09:19:37 +01:00
2023-12-07 13:50:28 +00:00
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:03 +01:00
2024-05-10 15:39:17 +01:00
2022-03-08 09:44:05 +00:00
2023-08-18 21:48:03 +01:00
2023-12-07 13:50:28 +00:00
2024-02-23 14:58:05 +00: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
2024-02-23 14:58:05 +00:00
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:03 +01:00
2024-02-23 16:02:02 +00:00
2023-08-22 08:07:52 +01:00
2023-12-07 13:50:28 +00:00
2023-08-18 21:48:03 +01:00
2024-05-10 15:39:17 +01:00
2023-06-15 09:19:37 +01:00
2023-08-18 21:48:03 +01:00
2023-11-01 10:02:14 +00:00
2024-05-03 10:07:06 +01:00
2024-05-03 10:07:02 +01:00
2024-05-03 10:07:04 +01:00
2023-07-03 10:55:04 -07:00
2023-12-07 13:50:26 +00:00
2023-11-01 10:02:14 +00:00
2023-08-18 21:48:03 +01:00
2023-11-01 10:02:14 +00:00
2023-06-15 09:19:38 +01:00
2023-11-01 10:02:17 +00:00
2023-12-07 13:50:28 +00:00
2023-11-01 10:02:15 +00: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-12-07 13:50:28 +00:00
2022-09-28 16:17:41 +01:00
2024-02-23 16:12:03 +00:00
2023-12-07 13:50:30 +00:00
2023-08-18 21:48:03 +01:00
2024-02-23 16:11:39 +00:00
2022-04-28 17:24:40 +01:00
2022-12-07 13:28:11 +00:00
2022-11-14 10:01:39 +01:00
2023-11-01 10:02:11 +00:00
2023-06-15 09:19:37 +01:00
2024-02-23 14:58:04 +00:00
2024-02-23 14:58:01 +00:00
2023-08-18 21:48:03 +01:00
2023-11-01 10:02:17 +00:00
2023-11-01 10:02:16 +00:00
2024-02-23 14:58:04 +00:00
2024-02-23 14:58:04 +00:00
2023-06-15 09:19:37 +01:00
2024-02-23 14:58:04 +00:00
2024-02-23 14:58:04 +00:00
2023-11-01 10:02:17 +00:00
2023-08-18 21:48:02 +01:00
2023-08-18 21:48:03 +01:00
2023-08-18 21:48:03 +01:00