Revert "pipes: fixed memory leak in error path"

This reverts commit f0bb5580eb04895f98388b9bc824c12c3bd71a39.
Revert "Revert "pipes: fixed memory leak in error path""

This reverts commit e9f6de7df256c0746a12cd5cf6f90362bd81d477.
Revert "Revert "Revert "pipes: fixed memory leak in error path"""

This reverts commit 177e00f9ab8d3d6aa39a8fd37e2c8cb13e0040a7.