Skip to content

Commit 1298a54

Browse files
committed
Merge tag 'drm-misc-fixes-2020-07-02' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
* dma-buf: fix a use-after-free bug * sun4i: remove HPD polling Signed-off-by: Dave Airlie <[email protected]> From: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20200702075143.GA25040@linux-uq9g
2 parents 80e8990 + bda8eaa commit 1298a54

File tree

2 files changed

+27
-32
lines changed

2 files changed

+27
-32
lines changed

drivers/dma-buf/dma-buf.c

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -54,37 +54,11 @@ static char *dmabuffs_dname(struct dentry *dentry, char *buffer, int buflen)
5454
dentry->d_name.name, ret > 0 ? name : "");
5555
}
5656

57-
static const struct dentry_operations dma_buf_dentry_ops = {
58-
.d_dname = dmabuffs_dname,
59-
};
60-
61-
static struct vfsmount *dma_buf_mnt;
62-
63-
static int dma_buf_fs_init_context(struct fs_context *fc)
64-
{
65-
struct pseudo_fs_context *ctx;
66-
67-
ctx = init_pseudo(fc, DMA_BUF_MAGIC);
68-
if (!ctx)
69-
return -ENOMEM;
70-
ctx->dops = &dma_buf_dentry_ops;
71-
return 0;
72-
}
73-
74-
static struct file_system_type dma_buf_fs_type = {
75-
.name = "dmabuf",
76-
.init_fs_context = dma_buf_fs_init_context,
77-
.kill_sb = kill_anon_super,
78-
};
79-
80-
static int dma_buf_release(struct inode *inode, struct file *file)
57+
static void dma_buf_release(struct dentry *dentry)
8158
{
8259
struct dma_buf *dmabuf;
8360

84-
if (!is_dma_buf_file(file))
85-
return -EINVAL;
86-
87-
dmabuf = file->private_data;
61+
dmabuf = dentry->d_fsdata;
8862

8963
BUG_ON(dmabuf->vmapping_counter);
9064

@@ -110,9 +84,32 @@ static int dma_buf_release(struct inode *inode, struct file *file)
11084
module_put(dmabuf->owner);
11185
kfree(dmabuf->name);
11286
kfree(dmabuf);
87+
}
88+
89+
static const struct dentry_operations dma_buf_dentry_ops = {
90+
.d_dname = dmabuffs_dname,
91+
.d_release = dma_buf_release,
92+
};
93+
94+
static struct vfsmount *dma_buf_mnt;
95+
96+
static int dma_buf_fs_init_context(struct fs_context *fc)
97+
{
98+
struct pseudo_fs_context *ctx;
99+
100+
ctx = init_pseudo(fc, DMA_BUF_MAGIC);
101+
if (!ctx)
102+
return -ENOMEM;
103+
ctx->dops = &dma_buf_dentry_ops;
113104
return 0;
114105
}
115106

107+
static struct file_system_type dma_buf_fs_type = {
108+
.name = "dmabuf",
109+
.init_fs_context = dma_buf_fs_init_context,
110+
.kill_sb = kill_anon_super,
111+
};
112+
116113
static int dma_buf_mmap_internal(struct file *file, struct vm_area_struct *vma)
117114
{
118115
struct dma_buf *dmabuf;
@@ -412,7 +409,6 @@ static void dma_buf_show_fdinfo(struct seq_file *m, struct file *file)
412409
}
413410

414411
static const struct file_operations dma_buf_fops = {
415-
.release = dma_buf_release,
416412
.mmap = dma_buf_mmap_internal,
417413
.llseek = dma_buf_llseek,
418414
.poll = dma_buf_poll,

drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,8 @@ sun4i_hdmi_connector_detect(struct drm_connector *connector, bool force)
259259
struct sun4i_hdmi *hdmi = drm_connector_to_sun4i_hdmi(connector);
260260
unsigned long reg;
261261

262-
if (readl_poll_timeout(hdmi->base + SUN4I_HDMI_HPD_REG, reg,
263-
reg & SUN4I_HDMI_HPD_HIGH,
264-
0, 500000)) {
262+
reg = readl(hdmi->base + SUN4I_HDMI_HPD_REG);
263+
if (reg & SUN4I_HDMI_HPD_HIGH) {
265264
cec_phys_addr_invalidate(hdmi->cec_adap);
266265
return connector_status_disconnected;
267266
}

0 commit comments

Comments
 (0)