Пример #1
0
static void
conn_free(struct conn *conn)
{
    log_debug(LOG_VVERB, "free conn %p id %"PRIu64"", conn, conn->id);
    mcp_free(conn);
}
Пример #2
0
/*------------------------------------------------------------------
 * Func : mcp_cipher_do_update
 *
 * Desc : open function of md dev
 *
 * Parm : inode : inode of dev
 *        file  : context of file
 *         
 * Retn : 0 : success, others fail  
 *------------------------------------------------------------------*/
static 
int mcp_cipher_do_update(
    MCP_CIPHER_CTX*         ctx, 
    unsigned char*          in,
    unsigned long           len,
    unsigned char*          out
    )
{       
    int outlen;
    unsigned char* buff = NULL;    
    
    if (mcp_is_pli_address(in) && mcp_is_pli_address(out))
        return MCP_CipherUpdate(ctx, pli_to_kernel(in), len, pli_to_kernel(out));        
        
    if ((buff = mcp_malloc(len))==NULL)
        goto err_alloc_kernel_buffer_failed;
            
    if (mcp_is_pli_address(in))               // input buffer is allocated by pli
    {
        if ((outlen = MCP_CipherUpdate(ctx, pli_to_kernel(in), len, buff))<0)
        {
            printk("[MCP][CIPHER] do cipher update failed, update failed\n");
            goto err_update_cipher_failed;
        }
        
        if (copy_to_user((void __user *) out, buff, outlen))    
        {
            printk("[MCP][CIPHER] do cipher update failed, copy data to user buffer failed\n");            
            goto err_copy_to_user_failed;
        }
    }
    else if (mcp_is_pli_address(out))         // output buffer is allocated by pli
    {
        if (copy_from_user((void *) buff, (void __user *)in, len))    
        {
            printk("[MCP][CIPHER] do cipher update failed, copy data from user space failed\n");            
            goto err_copy_from_user_failed;
        }           
        
        if ((outlen = MCP_CipherUpdate(ctx, buff, len, pli_to_kernel(out)))<0)
        {            
            printk("[MCP][CIPHER] do cipher update failed, update failed\n");
            goto err_update_cipher_failed;
        }
    }
    else                                // none of them are allocated by pli
    {
        if (copy_from_user((void *) buff, (void __user *)in, len))    
        {
            printk("[MCP][CIPHER] do cipher update failed, copy data from user space failed\n");
            outlen = -EFAULT;
            goto err_copy_from_user_failed;
        }           
        
        if ((outlen = MCP_CipherUpdate(ctx, buff, len, buff))<0)
        {            
            printk("[MCP][CIPHER] do cipher update failed, update failed\n");
            goto err_update_cipher_failed;
        }
        
        if (copy_to_user((void __user *) out, buff, outlen))    
        {
            printk("[MCP][CIPHER] do cipher update failed, copy data to user buffer failed\n");            
            goto err_copy_to_user_failed;
        }          
    }  
    
    mcp_free(buff, len);   

    return outlen;
    
//----------------------------------    
err_copy_from_user_failed:
err_copy_to_user_failed:        
err_update_cipher_failed:    
    mcp_free(buff, len);       
err_alloc_kernel_buffer_failed:        
    return -EFAULT;
}
Пример #3
0
static void
call_free(struct call *call)
{
    log_debug(LOG_VVERB, "free call %p id %"PRIu64"", call, call->id);
    mcp_free(call);
}