Skip to content

Commit 5c48d58

Browse files
author
itayzafrir
committed
Set handle to PSA_NULL_HANDLE when closing IPC connection
1 parent bf05154 commit 5c48d58

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

components/TARGET_PSA/services/crypto/COMPONENT_PSA_SRV_IPC/psa_crypto_spm.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static psa_status_t ipc_connect(uint32_t sid, psa_handle_t *handle)
4848
static inline void ipc_close(psa_handle_t *handle)
4949
{
5050
psa_close(*handle);
51+
*handle = PSA_NULL_HANDLE;
5152
}
5253

5354
static psa_status_t ipc_call(psa_handle_t *handle, psa_invec *in_vec, size_t in_vec_size,
@@ -99,7 +100,6 @@ psa_status_t psa_mac_abort(psa_mac_operation_t *operation)
99100
};
100101

101102
psa_status_t status = ipc_call(&operation->handle, in_vec, 1, NULL, 0, true);
102-
operation->handle = PSA_NULL_HANDLE;
103103
return (status);
104104
}
105105

@@ -167,7 +167,6 @@ psa_status_t psa_mac_sign_finish(psa_mac_operation_t *operation,
167167
};
168168

169169
psa_status_t status = ipc_call(&operation->handle, in_vec, 2, out_vec, 2, true);
170-
operation->handle = PSA_NULL_HANDLE;
171170
return (status);
172171
}
173172

@@ -183,7 +182,6 @@ psa_status_t psa_mac_verify_finish(psa_mac_operation_t *operation,
183182
};
184183

185184
psa_status_t status = ipc_call(&operation->handle, in_vec, 3, NULL, 0, true);
186-
operation->handle = PSA_NULL_HANDLE;
187185
return (status);
188186
}
189187

@@ -203,7 +201,6 @@ psa_status_t psa_hash_abort(psa_hash_operation_t *operation)
203201
};
204202

205203
psa_status_t status = ipc_call(&operation->handle, in_vec, 1, NULL, 0, true);
206-
operation->handle = PSA_NULL_HANDLE;
207204
return (status);
208205
}
209206

@@ -254,7 +251,6 @@ psa_status_t psa_hash_finish(psa_hash_operation_t *operation,
254251
};
255252

256253
status = ipc_call(&operation->handle, in_vec, 2, out_vec, 2, true);
257-
operation->handle = PSA_NULL_HANDLE;
258254
return (status);
259255
}
260256

@@ -270,7 +266,6 @@ psa_status_t psa_hash_verify(psa_hash_operation_t *operation,
270266
};
271267

272268
psa_status_t status = ipc_call(&operation->handle, in_vec, 3, NULL, 0, true);
273-
operation->handle = PSA_NULL_HANDLE;
274269
return (status);
275270
}
276271

@@ -310,7 +305,6 @@ psa_status_t psa_hash_clone(const psa_hash_operation_t *source_operation,
310305
exit:
311306
if (status != PSA_SUCCESS) {
312307
ipc_close(&target_operation->handle);
313-
target_operation->handle = PSA_NULL_HANDLE;
314308
}
315309
return (status);
316310
}
@@ -1025,7 +1019,6 @@ psa_status_t psa_generator_abort(psa_crypto_generator_t *generator)
10251019

10261020
if (generator->handle != PSA_NULL_HANDLE) {
10271021
status = ipc_call(&generator->handle, in_vec, 1, NULL, 0, true);
1028-
generator->handle = PSA_NULL_HANDLE;
10291022
}
10301023
return (status);
10311024
}
@@ -1155,7 +1148,6 @@ psa_status_t psa_cipher_finish(psa_cipher_operation_t *operation,
11551148
};
11561149

11571150
psa_status_t status = ipc_call(&operation->handle, in_vec, 1, out_vec, 2, true);
1158-
operation->handle = PSA_NULL_HANDLE;
11591151
return (status);
11601152
}
11611153

@@ -1173,7 +1165,6 @@ psa_status_t psa_cipher_abort(psa_cipher_operation_t *operation)
11731165
};
11741166

11751167
psa_status_t status = ipc_call(&operation->handle, in_vec, 1, NULL, 0, true);
1176-
operation->handle = PSA_NULL_HANDLE;
11771168
return (status);
11781169
}
11791170

0 commit comments

Comments
 (0)