aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2012-03-13 06:35:43 -0400
committerDave Airlie <airlied@redhat.com>2012-03-15 05:50:20 -0400
commitee34ab5b01e6e7cbd9438aeb6ccbd08d3727988e (patch)
tree74eb3f4bd68763c46f18df4c99c1789e795c5dff /drivers/gpu/drm
parent1dd6c8bda9aef72a819707cfc293917295af15d3 (diff)
drm: Fix memory leak in drm_mode_setcrtc()
The mode passed to the .set_config() hook was never freed. The drivers will make a copy of the mode, so simply free it when done. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/drm_crtc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index d2e09d98691a..9ccb92fdd7b2 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -643,6 +643,9 @@ EXPORT_SYMBOL(drm_mode_create);
643 */ 643 */
644void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode) 644void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode)
645{ 645{
646 if (!mode)
647 return;
648
646 drm_mode_object_put(dev, &mode->base); 649 drm_mode_object_put(dev, &mode->base);
647 650
648 kfree(mode); 651 kfree(mode);
@@ -1812,6 +1815,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
1812 } 1815 }
1813 1816
1814 mode = drm_mode_create(dev); 1817 mode = drm_mode_create(dev);
1818 if (!mode) {
1819 ret = -ENOMEM;
1820 goto out;
1821 }
1822
1815 drm_crtc_convert_umode(mode, &crtc_req->mode); 1823 drm_crtc_convert_umode(mode, &crtc_req->mode);
1816 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); 1824 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
1817 } 1825 }
@@ -1881,6 +1889,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
1881 1889
1882out: 1890out:
1883 kfree(connector_set); 1891 kfree(connector_set);
1892 drm_mode_destroy(dev, mode);
1884 mutex_unlock(&dev->mode_config.mutex); 1893 mutex_unlock(&dev->mode_config.mutex);
1885 return ret; 1894 return ret;
1886} 1895}