aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/crypto/ap_bus.h
diff options
context:
space:
mode:
authorHarald Freudenberger <freude@de.ibm.com>2018-05-28 13:00:42 +0200
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2018-05-30 11:18:05 +0200
commit89a0c0ec0d2e3ce0ee9caa00f60c0c26ccf11c21 (patch)
tree7e784683c6cb778d43b8b7fb4b3e73a78c19e533 /drivers/s390/crypto/ap_bus.h
parents390/archrandom: Rework arch random implementation. (diff)
downloadlinux-dev-89a0c0ec0d2e3ce0ee9caa00f60c0c26ccf11c21.tar.xz
linux-dev-89a0c0ec0d2e3ce0ee9caa00f60c0c26ccf11c21.zip
s390/zcrypt: Fix CCA and EP11 CPRB processing failure memory leak.
Tests showed, that the zcrypt device driver produces memory leaks when a valid CCA or EP11 CPRB can't get delivered or has a failure during processing within the zcrypt device driver. This happens when a invalid domain or adapter number is used or the lower level software or hardware layers produce any kind of failure during processing of the request. Only CPRBs send to CCA or EP11 cards can produce this memory leak. The accelerator and the CPRBs processed by this type of crypto card is not affected. The two fields message and private within the ap_message struct are allocated with pulling the function code for the CPRB but only freed when processing of the CPRB succeeds. So for example an invalid domain or adapter field causes the processing to fail, leaving these two memory areas allocated forever. Signed-off-by: Harald Freudenberger <freude@de.ibm.com> Reviewed-by: Ingo Franzki <ifranzki@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/crypto/ap_bus.h')
-rw-r--r--drivers/s390/crypto/ap_bus.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/s390/crypto/ap_bus.h b/drivers/s390/crypto/ap_bus.h
index 02184cf35834..6a273c5ebca5 100644
--- a/drivers/s390/crypto/ap_bus.h
+++ b/drivers/s390/crypto/ap_bus.h
@@ -198,11 +198,18 @@ struct ap_message {
*/
static inline void ap_init_message(struct ap_message *ap_msg)
{
- ap_msg->psmid = 0;
- ap_msg->length = 0;
- ap_msg->rc = 0;
- ap_msg->special = 0;
- ap_msg->receive = NULL;
+ memset(ap_msg, 0, sizeof(*ap_msg));
+}
+
+/**
+ * ap_release_message() - Release ap_message.
+ * Releases all memory used internal within the ap_message struct
+ * Currently this is the message and private field.
+ */
+static inline void ap_release_message(struct ap_message *ap_msg)
+{
+ kzfree(ap_msg->message);
+ kzfree(ap_msg->private);
}
#define for_each_ap_card(_ac) \