Commit 398180f
committed
KVM: TDX: Use struct_size to simplify tdx_get_capabilities()
Use struct_size() instead of manually calculating the number of bytes to
allocate for 'caps', including the nested flexible array, and copy all of
'caps' to user space with a single copy_to_user() call (thanks to the full
size being provided by struct_size()).
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Tested-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Link: https://patch.msgid.link/20251017213914.167301-1-thorsten.blum@linux.dev
[sean: separate from swap of get_user() vs. kzalloc() ordering]
Signed-off-by: Sean Christopherson <seanjc@google.com>1 parent 11b79f8 commit 398180f
1 file changed
+4
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2231 | 2231 | | |
2232 | 2232 | | |
2233 | 2233 | | |
2234 | | - | |
2235 | | - | |
2236 | | - | |
| 2234 | + | |
| 2235 | + | |
2237 | 2236 | | |
2238 | 2237 | | |
2239 | 2238 | | |
2240 | 2239 | | |
2241 | 2240 | | |
2242 | 2241 | | |
2243 | 2242 | | |
2244 | | - | |
| 2243 | + | |
| 2244 | + | |
2245 | 2245 | | |
2246 | 2246 | | |
2247 | 2247 | | |
2248 | 2248 | | |
2249 | | - | |
2250 | | - | |
2251 | | - | |
2252 | | - | |
2253 | | - | |
2254 | 2249 | | |
2255 | 2250 | | |
2256 | 2251 | | |
| |||
0 commit comments