Uploaded image for project: 'Embedded Software & Tools'
  1. Embedded Software & Tools
  2. EXT_EP-11894

Status Overwrite by ownPosixObjectFree() in tivxQueueCreate API

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Medium Medium
    • OpenVX Framework
    • TIOVX-1738
    • TIOVX_09.02.00
    • TIOVX_10.00.00
    • j784s4-evm

      The variable status is overwritten by ownPosixObjectFree() in tivxQueueCreate() in tivx_queue.c. To solve this temp_status  is used to get the status from ownPosixObjectFree().

       

      vx_status tivxQueueCreate(
          tivx_queue *queue, uint32_t max_elements, uintptr_t *queue_memory,
          uint32_t flags)
      {
          vx_status status = (vx_status)VX_FAILURE;
          uint32_t temp_status;
          tivx_queue_context context = NULL;    i
          if ((NULL != queue) && (NULL != queue_memory) && (0U != max_elements))
          {
              /*
               * init queue to 0's
               */
              init_queue(&queue);        /*
               * init queue with user parameters
               */
              queue->max_ele = max_elements;
              queue->flags = flags;        queue->queue = queue_memory;        queue->context = ownPosixObjectAlloc((vx_enum)TIVX_POSIX_TYPE_QUEUE);        context = queue->context;        if(queue->context==NULL)
              {
                  VX_PRINT(VX_ZONE_ERROR, "queue memory allocation failed\n");
                  status = (vx_status)VX_ERROR_NO_MEMORY;
              }
              else
              {
                      ..................
                      ...................
      
                  
                      if ((uint32_t)(queue->flags & TIVX_QUEUE_FLAG_BLOCK_ON_PUT) != (uint32_t)0)
                      {
                          pthread_condattr_t cond_attr;                    /*
                           * user requested block on queue put
                           */                    /*
                           * create cond for it
                           */
                          temp_status = (uint32_t)status | (uint32_t)pthread_condattr_init(&cond_attr);
                          status = (vx_status)temp_status;
                          temp_status = (uint32_t)status | (uint32_t)pthread_cond_init(&context->condPut, &cond_attr);
                          status = (vx_status)temp_status;                    (void)pthread_condattr_destroy(&cond_attr);
                      }
                  }
                  if ((vx_status)VX_SUCCESS == status)
                  {
                      queue->blockedOnGet = (vx_bool)vx_false_e;
                      queue->blockedOnPut = (vx_bool)vx_false_e;
                  }
      #ifdef LDRA_UNTESTABLE_CODE
      /* TIOVX-1727- LDRA Uncovered Id: TIOVX_CODE_COVERAGE_TIVX_QUEUE_UM001 */
                  else
                  {
                      (void)pthread_mutex_destroy(&context->lock);
                      temp_status = ownPosixObjectFree(queue->context, (vx_enum)TIVX_POSIX_TYPE_QUEUE);  ///BUG FIX
                      if ((vx_status)VX_SUCCESS != temp_status)
                      {
                          VX_PRINT(VX_ZONE_ERROR, "Queue free failed\n");
                          status = VX_FAILURE;
                      }
                      queue->context = NULL;
                  }
      #endif
              }
          }    return (status);
      }
      

       

       

       
       

            syncuser TI User
            syncuser TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: