Skip to content

Commit 22dd888

Browse files
moonlight83340cfriedt
authored andcommitted
drivers: tee: optee: fix possible null pointer dereference
Add check for supp->current being NULL before accessing num_params in error log. Prevent potential NULL pointer dereference and crash when invalid parameter count Improve error messages for better debugging in cases with no current request or wrong param count. Signed-off-by: Gaetan Perrot <[email protected]>
1 parent 56bf288 commit 22dd888

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/tee/optee/optee.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,12 @@ static int optee_suppl_send(const struct device *dev, unsigned int ret, unsigned
10931093
req = supp->current;
10941094
supp->current = NULL;
10951095
} else {
1096-
LOG_ERR("Invalid number of parameters, expected %lu got %u", req->num_params,
1097-
num_params);
1096+
if (supp->current) {
1097+
LOG_ERR("Invalid number of parameters, expected %lu or more, got %u",
1098+
supp->current->num_params, num_params);
1099+
} else {
1100+
LOG_ERR("No current request, but called with num_params=%u", num_params);
1101+
}
10981102
}
10991103
k_mutex_unlock(&supp->mutex);
11001104

0 commit comments

Comments
 (0)