linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ti.com>
To: Sebastian Reichel <sebastian.reichel@collabora.com>,
	Sebastian Reichel <sre@kernel.org>,
	Tony Lindgren <tony@atomide.com>, Pavel Machek <pavel@ucw.cz>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: "H. Nikolaus Schaller" <hns@goldelico.com>,
	<dri-devel@lists.freedesktop.org>, <linux-omap@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <kernel@collabora.com>
Subject: Re: [PATCHv4 4/6] drm/omap: fix incorrect union usage
Date: Fri, 16 Nov 2018 15:41:24 +0200	[thread overview]
Message-ID: <f64b580d-14ae-42df-34b9-a1f7c87e5f37@ti.com> (raw)
In-Reply-To: <20181115230645.15748-5-sebastian.reichel@collabora.com>

On 16/11/18 01:06, Sebastian Reichel wrote:
> The DSI encoder sets dssdev->ops->dsi.set_config, which is stored at the
> same offset as dssdev->ops->hdmi.set_hdmi_mode. The code in omap_encoder
> only checks if dssdev->ops->hdmi.set_hdmi_mode is NULL. Due to the way
> union works, it won't be NULL if dsi.set_config is set. This means
> dsi_set_config will be called with config=hdmi_mode=false=NULL parameter
> resulting in a NULL dereference. Also the dereference happens while
> console is locked, so kernel hangs without any debug output (can be
> avoided by fbmem's lockless_register_fb=1 parameter).
> 
> This fixes the issue by exiting early if the output type definitely
> has no hdmi_set operations.
> 
> Fixes: 83910ad3f51fb ("drm/omap: Move most omap_dss_driver operations to omap_dss_device_ops")
> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
> ---
>  drivers/gpu/drm/omapdrm/omap_encoder.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c
> index 32bbe3a80e7d..ba0099f0644c 100644
> --- a/drivers/gpu/drm/omapdrm/omap_encoder.c
> +++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
> @@ -122,6 +122,14 @@ static void omap_encoder_mode_set(struct drm_encoder *encoder,
>  
>  	dssdev = omap_encoder->output;
>  
> +	/* The following operations access dssdev->ops->hdmi, which is a union
> +	 * also used by DSI. This ensures, that the field does not have data
> +	 * for DSI (or any other future output type).
> +	 */
> +	if (dssdev->output_type != OMAP_DISPLAY_TYPE_HDMI &&
> +	    dssdev->output_type != OMAP_DISPLAY_TYPE_DVI)

Good catch.

Why DVI?

I think the whole code block starting from

/* Set the HDMI mode and HDMI infoframe if applicable. */

to the end of the function should be inside

if (dssdev->output_type == OMAP_DISPLAY_TYPE_HDMI)

 Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

  reply	other threads:[~2018-11-16 13:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-15 23:06 [PATCHv4 0/6] omapdrm: DSI command mode panel support Sebastian Reichel
2018-11-15 23:06 ` [PATCHv4 1/6] drm/omap: use DRM_DEBUG_DRIVER instead of CORE Sebastian Reichel
2018-11-17 21:01   ` Pavel Machek
2018-11-15 23:06 ` [PATCHv4 2/6] drm/omap: populate DSI platform bus earlier Sebastian Reichel
2018-11-17 21:02   ` Pavel Machek
2018-11-15 23:06 ` [PATCHv4 3/6] drm/omap: don't check dispc timings for DSI Sebastian Reichel
2018-11-17 21:04   ` Pavel Machek
2018-11-15 23:06 ` [PATCHv4 4/6] drm/omap: fix incorrect union usage Sebastian Reichel
2018-11-16 13:41   ` Tomi Valkeinen [this message]
2018-11-16 22:36     ` Sebastian Reichel
2018-11-15 23:06 ` [PATCHv4 5/6] drm/omap: add framedone interrupt support Sebastian Reichel
2018-11-17 21:08   ` Pavel Machek
2018-11-19 12:05     ` Sebastian Reichel
2018-11-19 12:12       ` Pavel Machek
2018-11-15 23:06 ` [PATCHv4 6/6] drm/omap: add support for manually updated displays Sebastian Reichel
2018-11-17 21:16   ` Pavel Machek
2018-11-16 22:09 ` [PATCHv4 0/6] omapdrm: DSI command mode panel support Tony Lindgren
2018-11-17 21:00 ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f64b580d-14ae-42df-34b9-a1f7c87e5f37@ti.com \
    --to=tomi.valkeinen@ti.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hns@goldelico.com \
    --cc=kernel@collabora.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=sebastian.reichel@collabora.com \
    --cc=sre@kernel.org \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).