udmabuf: use EBADFD in case we didn't got a memfd
authorGerd Hoffmann <kraxel@redhat.com>
Tue, 11 Sep 2018 13:42:12 +0000 (15:42 +0200)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 12 Sep 2018 06:21:31 +0000 (08:21 +0200)
Reported-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20180911134216.9760-10-kraxel@redhat.com
drivers/dma-buf/udmabuf.c

index a3d225f..e0465a9 100644 (file)
@@ -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;