Commit 683a0e63 authored by Gustavo A. R. Silva's avatar Gustavo A. R. Silva Committed by Gerd Hoffmann

dma-buf/udmabuf: Fix NULL pointer dereference in udmabuf_create

There is a potential execution path in which pointer memfd is NULL when
passed as argument to fput(), hence there is a NULL pointer dereference
in fput().

Fix this by null checking *memfd* before calling fput().

Addresses-Coverity-ID: 1473174 ("Explicit null dereferenced")
Fixes: fbb0de79 ("Add udmabuf misc device")
Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20180904190749.GA9308@embeddedor.comSigned-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent a3b815f0
...@@ -194,6 +194,7 @@ static long udmabuf_create(struct udmabuf_create_list *head, ...@@ -194,6 +194,7 @@ static long udmabuf_create(struct udmabuf_create_list *head,
while (pgbuf > 0) while (pgbuf > 0)
put_page(ubuf->pages[--pgbuf]); put_page(ubuf->pages[--pgbuf]);
err_free_ubuf: err_free_ubuf:
if (memfd)
fput(memfd); fput(memfd);
kfree(ubuf->pages); kfree(ubuf->pages);
kfree(ubuf); kfree(ubuf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment