From ea0a51bb9d96a53e0c3c510656bd2443e900339d Mon Sep 17 00:00:00 2001 From: Jianqun Xu Date: Tue, 3 Aug 2021 10:34:05 +0800 Subject: [PATCH] dma-buf: buffer should align to cacheline size Fixes: 0f4763b1c656 ("dma-buf: add DMA_BUF_IOCTL_SYNC_PARTIAL support") Change-Id: Iff8b633cb89337bba3f7693a28657034a6aa2223 Signed-off-by: Jianqun Xu --- drivers/dma-buf/dma-buf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index bf92ce7e4e3e..8f101e83caed 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -453,6 +454,9 @@ static long dma_buf_ioctl(struct file *file, if (sync_p.len == 0) return -EINVAL; + if ((sync_p.offset % cache_line_size()) || (sync_p.len % cache_line_size())) + return -EINVAL; + if (sync_p.len > dmabuf->size || sync_p.offset > dmabuf->size - sync_p.len) return -EINVAL;