B17: cros-libva export_prime: take num_objects (max 4) instead of always 4, so unused descriptor slots are not wrapped in OwnedFd and closed
Browse files at this commitf766a417b2a14fc856bd259c2e085807de3df4f2Parent: e5211311 changed file +1 -3
shims/cros-libva/src/surface.rsmodified+1 -3
| @@ -364,9 +364,7 @@ impl<D: SurfaceMemoryDescriptor> Surface<D> { | |||
| 364 | // to create "safe" descriptors outside of this method and thus from made up values, | 364 | // to create "safe" descriptors outside of this method and thus from made up values, |
| 365 | // violating the safety guarantee that our FDs are legit. | 365 | // violating the safety guarantee that our FDs are legit. |
| 366 | 366 | ||
| 367 | - let objects = (0..desc.num_objects as usize) | 367 | + let objects = (0..(desc.num_objects as usize).min(4)) |
| 368 | - // Make sure we don't go out of bounds. | ||
| 369 | - .take(4) | ||
| 370 | .map(|i| desc.objects[i]) | 368 | .map(|i| desc.objects[i]) |
| 371 | .map(|o| { | 369 | .map(|o| { |
| 372 | DrmPrimeSurfaceDescriptorObject { | 370 | DrmPrimeSurfaceDescriptorObject { |