]> git.baikalelectronics.ru Git - kernel.git/commit
vfio: ccw: fix cleanup if cp_prefetch fails
authorHalil Pasic <pasic@linux.vnet.ibm.com>
Tue, 24 Apr 2018 11:26:56 +0000 (13:26 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Fri, 27 Apr 2018 05:23:20 +0000 (07:23 +0200)
commit6b3977ae891a83b50f3c9b3d8b1dbee15e138ebe
treee284e7b12508c8ae0e95ce7d01e0fcda960246c8
parent5e04d120ed32cf3f1b027a86a03daeb25d18c02f
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: stable@vger.kernel.org #v4.12+
Acked-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Reviewed-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Signed-off-by: Halil Pasic <pasic@linux.vnet.ibm.com>
Signed-off-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Message-Id: <20180423110113.59385-2-bjsdjshi@linux.vnet.ibm.com>
[CH: fixed typos]
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/cio/vfio_ccw_cp.c