@@ -642,16 +642,17 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms,
642642 struct zcrypt_queue * zq , * pref_zq ;
643643 struct ap_message ap_msg ;
644644 unsigned int wgt = 0 , pref_wgt = 0 ;
645- unsigned int func_code ;
646- int cpen , qpen , qid = 0 , rc = - ENODEV ;
645+ unsigned int func_code = 0 ;
646+ int cpen , qpen , qid = 0 , rc ;
647647 struct module * mod ;
648648
649649 trace_s390_zcrypt_req (mex , TP_ICARSAMODEXPO );
650650
651- ap_init_message (& ap_msg );
651+ rc = ap_init_apmsg (& ap_msg );
652+ if (rc )
653+ goto out ;
652654
653655 if (mex -> outputdatalength < mex -> inputdatalength ) {
654- func_code = 0 ;
655656 rc = - EINVAL ;
656657 goto out ;
657658 }
@@ -728,7 +729,7 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms,
728729 spin_unlock (& zcrypt_list_lock );
729730
730731out :
731- ap_release_message (& ap_msg );
732+ ap_release_apmsg (& ap_msg );
732733 if (tr ) {
733734 tr -> last_rc = rc ;
734735 tr -> last_qid = qid ;
@@ -746,16 +747,17 @@ static long zcrypt_rsa_crt(struct ap_perms *perms,
746747 struct zcrypt_queue * zq , * pref_zq ;
747748 struct ap_message ap_msg ;
748749 unsigned int wgt = 0 , pref_wgt = 0 ;
749- unsigned int func_code ;
750- int cpen , qpen , qid = 0 , rc = - ENODEV ;
750+ unsigned int func_code = 0 ;
751+ int cpen , qpen , qid = 0 , rc ;
751752 struct module * mod ;
752753
753754 trace_s390_zcrypt_req (crt , TP_ICARSACRT );
754755
755- ap_init_message (& ap_msg );
756+ rc = ap_init_apmsg (& ap_msg );
757+ if (rc )
758+ goto out ;
756759
757760 if (crt -> outputdatalength < crt -> inputdatalength ) {
758- func_code = 0 ;
759761 rc = - EINVAL ;
760762 goto out ;
761763 }
@@ -832,7 +834,7 @@ static long zcrypt_rsa_crt(struct ap_perms *perms,
832834 spin_unlock (& zcrypt_list_lock );
833835
834836out :
835- ap_release_message (& ap_msg );
837+ ap_release_apmsg (& ap_msg );
836838 if (tr ) {
837839 tr -> last_rc = rc ;
838840 tr -> last_qid = qid ;
@@ -850,15 +852,18 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms,
850852 struct zcrypt_queue * zq , * pref_zq ;
851853 struct ap_message ap_msg ;
852854 unsigned int wgt = 0 , pref_wgt = 0 ;
853- unsigned int func_code ;
855+ unsigned int func_code = 0 ;
854856 unsigned short * domain , tdom ;
855- int cpen , qpen , qid = 0 , rc = - ENODEV ;
857+ int cpen , qpen , qid = 0 , rc ;
856858 struct module * mod ;
857859
858860 trace_s390_zcrypt_req (xcrb , TB_ZSECSENDCPRB );
859861
860862 xcrb -> status = 0 ;
861- ap_init_message (& ap_msg );
863+
864+ rc = ap_init_apmsg (& ap_msg );
865+ if (rc )
866+ goto out ;
862867
863868 rc = prep_cca_ap_msg (userspace , xcrb , & ap_msg , & func_code , & domain );
864869 if (rc )
@@ -962,7 +967,7 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms,
962967 spin_unlock (& zcrypt_list_lock );
963968
964969out :
965- ap_release_message (& ap_msg );
970+ ap_release_apmsg (& ap_msg );
966971 if (tr ) {
967972 tr -> last_rc = rc ;
968973 tr -> last_qid = qid ;
@@ -1033,14 +1038,16 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms,
10331038 struct ep11_target_dev * targets ;
10341039 unsigned short target_num ;
10351040 unsigned int wgt = 0 , pref_wgt = 0 ;
1036- unsigned int func_code , domain ;
1041+ unsigned int func_code = 0 , domain ;
10371042 struct ap_message ap_msg ;
1038- int cpen , qpen , qid = 0 , rc = - ENODEV ;
1043+ int cpen , qpen , qid = 0 , rc ;
10391044 struct module * mod ;
10401045
10411046 trace_s390_zcrypt_req (xcrb , TP_ZSENDEP11CPRB );
10421047
1043- ap_init_message (& ap_msg );
1048+ rc = ap_init_apmsg (& ap_msg );
1049+ if (rc )
1050+ goto out ;
10441051
10451052 target_num = (unsigned short )xcrb -> targets_num ;
10461053
@@ -1164,7 +1171,7 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms,
11641171out_free :
11651172 kfree (targets );
11661173out :
1167- ap_release_message (& ap_msg );
1174+ ap_release_apmsg (& ap_msg );
11681175 if (tr ) {
11691176 tr -> last_rc = rc ;
11701177 tr -> last_qid = qid ;
@@ -1204,15 +1211,17 @@ static long zcrypt_rng(char *buffer)
12041211 struct zcrypt_card * zc , * pref_zc ;
12051212 struct zcrypt_queue * zq , * pref_zq ;
12061213 unsigned int wgt = 0 , pref_wgt = 0 ;
1207- unsigned int func_code ;
1214+ unsigned int func_code = 0 ;
12081215 struct ap_message ap_msg ;
12091216 unsigned int domain ;
12101217 int qid = 0 , rc = - ENODEV ;
12111218 struct module * mod ;
12121219
12131220 trace_s390_zcrypt_req (buffer , TP_HWRNGCPRB );
12141221
1215- ap_init_message (& ap_msg );
1222+ rc = ap_init_apmsg (& ap_msg );
1223+ if (rc )
1224+ goto out ;
12161225 rc = prep_rng_ap_msg (& ap_msg , & func_code , & domain );
12171226 if (rc )
12181227 goto out ;
@@ -1258,7 +1267,7 @@ static long zcrypt_rng(char *buffer)
12581267 spin_unlock (& zcrypt_list_lock );
12591268
12601269out :
1261- ap_release_message (& ap_msg );
1270+ ap_release_apmsg (& ap_msg );
12621271 trace_s390_zcrypt_rep (buffer , func_code , rc ,
12631272 AP_QID_CARD (qid ), AP_QID_QUEUE (qid ));
12641273 return rc ;
0 commit comments