]> git.baikalelectronics.ru Git - kernel.git/commit
s390/zcrypt: fix zcard and zqueue hot-unplug memleak
authorHarald Freudenberger <freude@linux.ibm.com>
Thu, 15 Apr 2021 09:22:03 +0000 (11:22 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Wed, 21 Apr 2021 10:32:12 +0000 (12:32 +0200)
commitb02238e476ab8c8c915a495b9b46d340c8fa16c4
tree97fbc8970a029a6e3166e09b3e580f9782844ce8
parent2de0518ed6790f016da120257d00452bc2eeee2c
s390/zcrypt: fix zcard and zqueue hot-unplug memleak

Tests with kvm and a kmemdebug kernel showed, that on hot unplug the
zcard and zqueue structs for the unplugged card or queue are not
properly freed because of a mismatch with get/put for the embedded
kref counter.

This fix now adjusts the handling of the kref counters. With init the
kref counter starts with 1. This initial value needs to drop to zero
with the unregister of the card or queue to trigger the release and
free the object.

Fixes: 43860aab8cec ("s390/ap: fix ap devices reference counting")
Reported-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Cc: stable@vger.kernel.org
Reviewed-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
drivers/s390/crypto/zcrypt_card.c
drivers/s390/crypto/zcrypt_queue.c