Skip to content

Commit b7b3f66

Browse files
committed
Merge tag 'drm-misc-fixes-2018-03-22' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
Main change is a patch to reject getfb call for multiplanar framebuffers, then we have a couple of error path fixes on the sun4i driver. Still on that driver there is a clk fix and finally a mmap offset fix on the udl driver. * tag 'drm-misc-fixes-2018-03-22' of git://anongit.freedesktop.org/drm/drm-misc: drm: udl: Properly check framebuffer mmap offsets drm: Reject getfb for multi-plane framebuffers drm/sun4i: hdmi: Fix another error handling path in 'sun4i_hdmi_bind()' drm/sun4i: hdmi: Fix an error handling path in 'sun4i_hdmi_bind()' drm/sun4i: Fix an error handling path in 'sun4i_drv_bind()' drm/sun4i: Fix exclusivity of the TCON clocks
2 parents 8c2d689 + 3b82a4d commit b7b3f66

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

drivers/gpu/drm/drm_framebuffer.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,12 @@ int drm_mode_getfb(struct drm_device *dev,
461461
if (!fb)
462462
return -ENOENT;
463463

464+
/* Multi-planar framebuffers need getfb2. */
465+
if (fb->format->num_planes > 1) {
466+
ret = -EINVAL;
467+
goto out;
468+
}
469+
464470
r->height = fb->height;
465471
r->width = fb->width;
466472
r->depth = fb->format->depth;
@@ -484,6 +490,7 @@ int drm_mode_getfb(struct drm_device *dev,
484490
ret = -ENODEV;
485491
}
486492

493+
out:
487494
drm_framebuffer_put(fb);
488495

489496
return ret;

drivers/gpu/drm/sun4i/sun4i_drv.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static int sun4i_drv_bind(struct device *dev)
111111
/* drm_vblank_init calls kcalloc, which can fail */
112112
ret = drm_vblank_init(drm, drm->mode_config.num_crtc);
113113
if (ret)
114-
goto free_mem_region;
114+
goto cleanup_mode_config;
115115

116116
drm->irq_enabled = true;
117117

@@ -139,7 +139,6 @@ static int sun4i_drv_bind(struct device *dev)
139139
sun4i_framebuffer_free(drm);
140140
cleanup_mode_config:
141141
drm_mode_config_cleanup(drm);
142-
free_mem_region:
143142
of_reserved_mem_device_release(dev);
144143
free_drm:
145144
drm_dev_unref(drm);

drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,8 @@ static int sun4i_hdmi_bind(struct device *dev, struct device *master,
538538
&sun4i_hdmi_regmap_config);
539539
if (IS_ERR(hdmi->regmap)) {
540540
dev_err(dev, "Couldn't create HDMI encoder regmap\n");
541-
return PTR_ERR(hdmi->regmap);
541+
ret = PTR_ERR(hdmi->regmap);
542+
goto err_disable_mod_clk;
542543
}
543544

544545
ret = sun4i_tmds_create(hdmi);
@@ -551,7 +552,8 @@ static int sun4i_hdmi_bind(struct device *dev, struct device *master,
551552
hdmi->ddc_parent_clk = devm_clk_get(dev, "ddc");
552553
if (IS_ERR(hdmi->ddc_parent_clk)) {
553554
dev_err(dev, "Couldn't get the HDMI DDC clock\n");
554-
return PTR_ERR(hdmi->ddc_parent_clk);
555+
ret = PTR_ERR(hdmi->ddc_parent_clk);
556+
goto err_disable_mod_clk;
555557
}
556558
} else {
557559
hdmi->ddc_parent_clk = hdmi->tmds_clk;

drivers/gpu/drm/sun4i/sun4i_tcon.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ static void sun4i_tcon_channel_set_status(struct sun4i_tcon *tcon, int channel,
103103

104104
if (enabled) {
105105
clk_prepare_enable(clk);
106+
clk_rate_exclusive_get(clk);
106107
} else {
107108
clk_rate_exclusive_put(clk);
108109
clk_disable_unprepare(clk);
@@ -262,7 +263,7 @@ static void sun4i_tcon0_mode_set_common(struct sun4i_tcon *tcon,
262263
const struct drm_display_mode *mode)
263264
{
264265
/* Configure the dot clock */
265-
clk_set_rate_exclusive(tcon->dclk, mode->crtc_clock * 1000);
266+
clk_set_rate(tcon->dclk, mode->crtc_clock * 1000);
266267

267268
/* Set the resolution */
268269
regmap_write(tcon->regs, SUN4I_TCON0_BASIC0_REG,
@@ -423,7 +424,7 @@ static void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon,
423424
WARN_ON(!tcon->quirks->has_channel_1);
424425

425426
/* Configure the dot clock */
426-
clk_set_rate_exclusive(tcon->sclk1, mode->crtc_clock * 1000);
427+
clk_set_rate(tcon->sclk1, mode->crtc_clock * 1000);
427428

428429
/* Adjust clock delay */
429430
clk_delay = sun4i_tcon_get_clk_delay(mode, 1);

drivers/gpu/drm/udl/udl_fb.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,15 @@ static int udl_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
159159
{
160160
unsigned long start = vma->vm_start;
161161
unsigned long size = vma->vm_end - vma->vm_start;
162-
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
162+
unsigned long offset;
163163
unsigned long page, pos;
164164

165-
if (offset + size > info->fix.smem_len)
165+
if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT))
166+
return -EINVAL;
167+
168+
offset = vma->vm_pgoff << PAGE_SHIFT;
169+
170+
if (offset > info->fix.smem_len || size > info->fix.smem_len - offset)
166171
return -EINVAL;
167172

168173
pos = (unsigned long)info->fix.smem_start + offset;

0 commit comments

Comments
 (0)