vfio: ccw: fix cleanup if cp_prefetch fails
If the translation of a channel program fails, we may end up attempting
to clean up (free, unpin) stuff that never got translated (and allocated,
pinned) in the first place.
By adjusting the lengths of the chains accordingly (so the element that
failed, and all subsequent elements are excluded) cleanup activities
based on false assumptions can be avoided.
Let's make sure cp_free works properly after cp_prefetch returns with an
error by setting ch_len of a ccw chain to the number of the translated
CCWs on that chain.
Cc: email@example.com #v4.12+
Acked-by: Pierre Morel <firstname.lastname@example.org>
Reviewed-by: Dong Jia Shi <email@example.com>
Signed-off-by: Halil Pasic <firstname.lastname@example.org>
Signed-off-by: Dong Jia Shi <email@example.com>
[CH: fixed typos]
Signed-off-by: Cornelia Huck <firstname.lastname@example.org>
1 file changed