libsp: Fix buffer boundary check in sp_discovery
Fix verification if RX buffer can hold returned partition descriptors.
Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: I062f08816e4de6dc37f4bcd69c114e0cf6ce698e
diff --git a/components/messaging/ffa/libsp/sp_discovery.c b/components/messaging/ffa/libsp/sp_discovery.c
index a801167..1f512a7 100644
--- a/components/messaging/ffa/libsp/sp_discovery.c
+++ b/components/messaging/ffa/libsp/sp_discovery.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
/*
- * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
*/
#include "sp_discovery.h"
@@ -64,7 +64,7 @@
return SP_RESULT_FFA(ffa_res);
}
- if (*count * sizeof(struct ffa_partition_information) < buffer_size) {
+ if ((*count * sizeof(struct ffa_partition_information)) > buffer_size) {
/*
* The indicated amount of info structures doesn't fit into the
* RX buffer.