In the Linux kernel, the following vulnerability has been resolved:
s390/vfioccw: Free all memory if cpinit() fails
The routine cpfree() is called to unpin/free any memory once an I/O is completed successfully, or if cpprefetch() fails. But if cp_init() fails, and cp->initialized is not enabled, the same routine cannot be used to free all the memory.
An attempt to address this exists in ccwchainhandleccw(), where a single call to ccwchain_free() is made for the currently-processed CCW segment. But this will leak other segments (created as a result of a Transfer in Channel) that had been allocated as part of the same channel program.
Address this by performing the cleanup outside of the recursive ccwchainhandleccw()/ccwchainlooptic() logic.