From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gerd Hoffmann Subject: [PATCH v2 09/13] udmabuf: use EBADFD in case we didn't got a memfd Date: Tue, 11 Sep 2018 15:42:12 +0200 Message-ID: <20180911134216.9760-10-kraxel@redhat.com> References: <20180911134216.9760-1-kraxel@redhat.com> Return-path: In-Reply-To: <20180911134216.9760-1-kraxel@redhat.com> Sender: linux-kernel-owner@vger.kernel.org To: dri-devel@lists.freedesktop.org Cc: laurent.pinchart@ideasonboard.com, daniel@ffwll.ch, Gerd Hoffmann , Sumit Semwal , "open list:DMA BUFFER SHARING FRAMEWORK" , "moderated list:DMA BUFFER SHARING FRAMEWORK" , open list List-Id: dri-devel@lists.freedesktop.org Reported-by: Laurent Pinchart Signed-off-by: Gerd Hoffmann Acked-by: Daniel Vetter --- drivers/dma-buf/udmabuf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index e821361566..652707f993 100644 --- a/drivers/dma-buf/udmabuf.c +++ b/drivers/dma-buf/udmabuf.c @@ -154,14 +154,17 @@ static long udmabuf_create(const struct udmabuf_create_list *head, pgbuf = 0; for (i = 0; i < head->count; i++) { + ret = -EBADFD; memfd = fget(list[i].memfd); if (!memfd) goto err; if (!shmem_mapping(file_inode(memfd)->i_mapping)) goto err; seals = memfd_fcntl(memfd, F_GET_SEALS, 0); - if (seals == -EINVAL || - (seals & SEALS_WANTED) != SEALS_WANTED || + if (seals == -EINVAL) + goto err; + ret = -EINVAL; + if ((seals & SEALS_WANTED) != SEALS_WANTED || (seals & SEALS_DENIED) != 0) goto err; pgoff = list[i].offset >> PAGE_SHIFT; -- 2.9.3