From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= Subject: Re: [PATCH 2/3] drm/i915/sdvo: Robustify the dtd<->drm_mode conversions Date: Tue, 10 Sep 2013 13:26:20 +0300 Message-ID: <20130910102620.GL11428@intel.com> References: <1378807612-18399-1-git-send-email-daniel.vetter@ffwll.ch> <1378807612-18399-2-git-send-email-daniel.vetter@ffwll.ch> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by gabe.freedesktop.org (Postfix) with ESMTP id F3962E6D1A for ; Tue, 10 Sep 2013 03:26:24 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1378807612-18399-2-git-send-email-daniel.vetter@ffwll.ch> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Daniel Vetter Cc: Intel Graphics Development List-Id: intel-gfx@lists.freedesktop.org On Tue, Sep 10, 2013 at 12:06:51PM +0200, Daniel Vetter wrote: > We've failed to properly clear out the flags when converting a dtd to > a drm mode. For more paranoia just memset the entire structure (and > drop the now redundant clears). > = > Also since > = > commit 135c81b8c3c9a70d7b55758c9c2a247a4abb7b64 > Author: Daniel Vetter > Date: Sun Jul 21 21:37:09 2013 +0200 > = > drm/i915: clean up crtc timings computation > = > we don't update the crtc timings any more properly, so do that again. > = > Cc: Rodrigo Vivi > Cc: Jesse Barnes > Cc: Ville Syrj=E4l=E4 > Reported-by: Ville Syrj=E4l=E4 > Signed-off-by: Daniel Vetter > --- > drivers/gpu/drm/i915/intel_sdvo.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > = > diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/int= el_sdvo.c > index 5033c74..d4a046d 100644 > --- a/drivers/gpu/drm/i915/intel_sdvo.c > +++ b/drivers/gpu/drm/i915/intel_sdvo.c > @@ -788,6 +788,8 @@ static void intel_sdvo_get_dtd_from_mode(struct intel= _sdvo_dtd *dtd, > uint16_t h_sync_offset, v_sync_offset; > int mode_clock; > = > + memset(dtd, 0, sizeof(*dtd)); > + > width =3D mode->hdisplay; > height =3D mode->vdisplay; > = > @@ -830,14 +832,14 @@ static void intel_sdvo_get_dtd_from_mode(struct int= el_sdvo_dtd *dtd, > if (mode->flags & DRM_MODE_FLAG_PVSYNC) > dtd->part2.dtd_flags |=3D DTD_FLAG_VSYNC_POSITIVE; > = > - dtd->part2.sdvo_flags =3D 0; > dtd->part2.v_sync_off_high =3D v_sync_offset & 0xc0; > - dtd->part2.reserved =3D 0; > } > = > static void intel_sdvo_get_mode_from_dtd(struct drm_display_mode * mode, > const struct intel_sdvo_dtd *dtd) > { > + memset(mode, 0, sizeof(*mode)); I have a theoretical worry that someone might end up calling this on a mode that sits on some list or was actually allocated and has a proper object id which we'd leak here. To make it totally safe you could populate a pristine mode struct and use drm_mode_copy() to overwrite adjusted_mode. Assuming we're not so short on stack space that our oversized mode struct would cause issues. Other options would be to add some WARNs to catch wrongdoers, or embed a temp mode for this purpose inside the intel_sdvo struct. > + > mode->hdisplay =3D dtd->part1.h_active; > mode->hdisplay +=3D ((dtd->part1.h_high >> 4) & 0x0f) << 8; > mode->hsync_start =3D mode->hdisplay + dtd->part2.h_sync_off; > @@ -872,6 +874,8 @@ static void intel_sdvo_get_mode_from_dtd(struct drm_d= isplay_mode * mode, Somewhere around these parts we have: 'mode->flags &=3D ~(DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC);' It can now be eliminated. > mode->flags |=3D DRM_MODE_FLAG_PVSYNC; > else > mode->flags |=3D DRM_MODE_FLAG_NVSYNC; > + > + drm_mode_set_crtcinfo(mode); > } > = > static bool intel_sdvo_check_supp_encode(struct intel_sdvo *intel_sdvo) > -- = > 1.8.4.rc3 -- = Ville Syrj=E4l=E4 Intel OTC