[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210510102015.251040265@linuxfoundation.org>
Date: Mon, 10 May 2021 12:16:40 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Marc Hartmayer <mhartmay@...ux.ibm.com>,
Harald Freudenberger <freude@...ux.ibm.com>,
Julian Wiedmann <jwi@...ux.ibm.com>,
Heiko Carstens <hca@...ux.ibm.com>
Subject: [PATCH 5.12 011/384] s390/zcrypt: fix zcard and zqueue hot-unplug memleak
From: Harald Freudenberger <freude@...ux.ibm.com>
commit 70fac8088cfad9f3b379c9082832b4d7532c16c2 upstream.
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: 29c2680fd2bf ("s390/ap: fix ap devices reference counting")
Reported-by: Marc Hartmayer <mhartmay@...ux.ibm.com>
Signed-off-by: Harald Freudenberger <freude@...ux.ibm.com>
Cc: stable@...r.kernel.org
Reviewed-by: Julian Wiedmann <jwi@...ux.ibm.com>
Signed-off-by: Heiko Carstens <hca@...ux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
---
drivers/s390/crypto/zcrypt_card.c | 1 +
drivers/s390/crypto/zcrypt_queue.c | 1 +
2 files changed, 2 insertions(+)
--- a/drivers/s390/crypto/zcrypt_card.c
+++ b/drivers/s390/crypto/zcrypt_card.c
@@ -192,5 +192,6 @@ void zcrypt_card_unregister(struct zcryp
spin_unlock(&zcrypt_list_lock);
sysfs_remove_group(&zc->card->ap_dev.device.kobj,
&zcrypt_card_attr_group);
+ zcrypt_card_put(zc);
}
EXPORT_SYMBOL(zcrypt_card_unregister);
--- a/drivers/s390/crypto/zcrypt_queue.c
+++ b/drivers/s390/crypto/zcrypt_queue.c
@@ -223,5 +223,6 @@ void zcrypt_queue_unregister(struct zcry
sysfs_remove_group(&zq->queue->ap_dev.device.kobj,
&zcrypt_queue_attr_group);
zcrypt_card_put(zc);
+ zcrypt_queue_put(zq);
}
EXPORT_SYMBOL(zcrypt_queue_unregister);
Powered by blists - more mailing lists