kernel: pipes: fix race condition
kernel: pipes: fix race condition

Fixes a race condition in the k_pipe_cleanup() routine by adding
a spinlock. Additionally, internal counters are now reset after
freeing the buffer as the pipe has now become a bufferless pipe.

Signed-off-by: Peter Mitsis <22bf95476f8cdbda3c8a9a9bf1bdda876f69ea7a@intel.com>

galak/zephyr,zephyrproject-rtos/zephyr,zephyrproject-rtos/zephyr,finikorg/zephyr,galak/zephyr,finikorg/zephyr,zephyrproject-rtos/zephyr,galak/zephyr,zephyrproject-rtos/zephyr,galak/zephyr,finikorg/zephyr,finikorg/zephyr,finikorg/zephyr,zephyrproject-rtos/zephyr,galak/zephyr