diff mbox

linux-generic: queue: check invalid handle in odp_queue_destroy

Message ID 1453808322-6775-1-git-send-email-maxim.uvarov@linaro.org
State Accepted
Commit ee90f447a6f5c76ab7751e6b747d1da3ac407fb1
Headers show

Commit Message

Maxim Uvarov Jan. 26, 2016, 11:38 a.m. UTC
Avoid seg. fault if invalid handle provided to queue destroy.

Reviewed-by: Zoltan Kiss <zoltan.kiss@linaro.org>
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
---
 platform/linux-generic/odp_queue.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Maxim Uvarov Jan. 29, 2016, 8:58 a.m. UTC | #1
Merged,
Maxim.

On 01/26/2016 14:38, Maxim Uvarov wrote:
> Avoid seg. fault if invalid handle provided to queue destroy.
>
> Reviewed-by: Zoltan Kiss <zoltan.kiss@linaro.org>
> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
> ---
>   platform/linux-generic/odp_queue.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c
> index e39176c..7f11478 100644
> --- a/platform/linux-generic/odp_queue.c
> +++ b/platform/linux-generic/odp_queue.c
> @@ -308,6 +308,9 @@ int odp_queue_destroy(odp_queue_t handle)
>   	queue_entry_t *queue;
>   	queue = queue_to_qentry(handle);
>   
> +	if (handle == ODP_QUEUE_INVALID)
> +		return -1;
> +
>   	LOCK(&queue->s.lock);
>   	if (queue->s.status == QUEUE_STATUS_FREE) {
>   		UNLOCK(&queue->s.lock);
diff mbox

Patch

diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c
index e39176c..7f11478 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -308,6 +308,9 @@  int odp_queue_destroy(odp_queue_t handle)
 	queue_entry_t *queue;
 	queue = queue_to_qentry(handle);
 
+	if (handle == ODP_QUEUE_INVALID)
+		return -1;
+
 	LOCK(&queue->s.lock);
 	if (queue->s.status == QUEUE_STATUS_FREE) {
 		UNLOCK(&queue->s.lock);