diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 355da57ae386..1a277f068248 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -274,6 +274,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alter_mutex_list_add); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_unlock_slowpath); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_wake_finish); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dma_buf_release); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dmabuf_heap_flags_validation); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_pass_input_event); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_check_status); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_blk_alloc_rqs); diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c index 53d8ee80a26d..c372cb9f24df 100644 --- a/drivers/dma-buf/dma-heap.c +++ b/drivers/dma-buf/dma-heap.c @@ -20,6 +20,8 @@ #include #include +#include + #define DEVNAME "dma_heap" #define NUM_HEAP_MINORS 128 @@ -80,10 +82,15 @@ struct dma_buf *dma_heap_buffer_alloc(struct dma_heap *heap, size_t len, unsigned int fd_flags, unsigned int heap_flags) { + bool vh_valid = false; + + trace_android_vh_dmabuf_heap_flags_validation(heap, + len, fd_flags, heap_flags, &vh_valid); + if (fd_flags & ~DMA_HEAP_VALID_FD_FLAGS) return ERR_PTR(-EINVAL); - if (heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS) + if (heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS && !vh_valid) return ERR_PTR(-EINVAL); /* * Allocations from all heaps have to begin diff --git a/include/trace/hooks/dmabuf.h b/include/trace/hooks/dmabuf.h index 31ac68577522..666aa5abe11d 100644 --- a/include/trace/hooks/dmabuf.h +++ b/include/trace/hooks/dmabuf.h @@ -16,6 +16,12 @@ struct dma_buf; DECLARE_HOOK(android_vh_dma_buf_release, TP_PROTO(struct dma_buf *data), TP_ARGS(data)); + +struct dma_heap; +DECLARE_HOOK(android_vh_dmabuf_heap_flags_validation, + TP_PROTO(struct dma_heap *heap, size_t len, + unsigned int fd_flags, unsigned int heap_flags, bool *skip), + TP_ARGS(heap, len, fd_flags, heap_flags, skip)); #endif /* _TRACE_HOOK_DMABUF_H */ /* This part must be outside protection */ #include