Skip to content

Commit 70fac80

Browse files
hfreudehcahca
authored andcommitted
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: 29c2680 ("s390/ap: fix ap devices reference counting") Reported-by: Marc Hartmayer <[email protected]> Signed-off-by: Harald Freudenberger <[email protected]> Cc: [email protected] Reviewed-by: Julian Wiedmann <[email protected]> Signed-off-by: Heiko Carstens <[email protected]>
1 parent 81bbf03 commit 70fac80

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

drivers/s390/crypto/zcrypt_card.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,6 @@ void zcrypt_card_unregister(struct zcrypt_card *zc)
192192
spin_unlock(&zcrypt_list_lock);
193193
sysfs_remove_group(&zc->card->ap_dev.device.kobj,
194194
&zcrypt_card_attr_group);
195+
zcrypt_card_put(zc);
195196
}
196197
EXPORT_SYMBOL(zcrypt_card_unregister);

drivers/s390/crypto/zcrypt_queue.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,5 +223,6 @@ void zcrypt_queue_unregister(struct zcrypt_queue *zq)
223223
sysfs_remove_group(&zq->queue->ap_dev.device.kobj,
224224
&zcrypt_queue_attr_group);
225225
zcrypt_card_put(zc);
226+
zcrypt_queue_put(zq);
226227
}
227228
EXPORT_SYMBOL(zcrypt_queue_unregister);

0 commit comments

Comments
 (0)