mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-05 17:16:50 +08:00
fix[ext_dma]: fix mmap permission error
Change-Id: Ic7ae7c8de978752f8437f2d0b700014ea6817c56 Signed-off-by: Yanjun Liao <yanjun.liao@rock-chips.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "mpp_mem.h"
|
#include "mpp_mem.h"
|
||||||
#include "mpp_debug.h"
|
#include "mpp_debug.h"
|
||||||
|
#include "mpp_common.h"
|
||||||
|
|
||||||
#include "allocator_ext_dma.h"
|
#include "allocator_ext_dma.h"
|
||||||
|
|
||||||
@@ -87,6 +88,7 @@ static MPP_RET allocator_ext_dma_import(void *ctx, MppBufferInfo *info)
|
|||||||
static MPP_RET allocator_ext_dma_mmap(void *ctx, MppBufferInfo *info)
|
static MPP_RET allocator_ext_dma_mmap(void *ctx, MppBufferInfo *info)
|
||||||
{
|
{
|
||||||
void *ptr = NULL;
|
void *ptr = NULL;
|
||||||
|
int flags = 0;
|
||||||
unsigned long offset = 0L;
|
unsigned long offset = 0L;
|
||||||
mpp_assert(ctx);
|
mpp_assert(ctx);
|
||||||
mpp_assert(info->size);
|
mpp_assert(info->size);
|
||||||
@@ -99,8 +101,11 @@ static MPP_RET allocator_ext_dma_mmap(void *ctx, MppBufferInfo *info)
|
|||||||
* It is insecure to access the first memory page,
|
* It is insecure to access the first memory page,
|
||||||
* usually system doesn't allow this behavior.
|
* usually system doesn't allow this behavior.
|
||||||
*/
|
*/
|
||||||
ptr = mmap(NULL, info->size, PROT_READ | PROT_WRITE,
|
flags = PROT_READ;
|
||||||
MAP_SHARED, info->fd, offset);
|
if (fcntl(info->fd, F_GETFL) & O_RDWR)
|
||||||
|
flags |= PROT_WRITE;
|
||||||
|
|
||||||
|
ptr = mmap(NULL, info->size, flags, MAP_SHARED, info->fd, offset);
|
||||||
if (ptr == MAP_FAILED)
|
if (ptr == MAP_FAILED)
|
||||||
return MPP_ERR_NULL_PTR;
|
return MPP_ERR_NULL_PTR;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user