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: [PATCHv5 4/6] drm/omap: fix incorrect union usage
Date: Mon, 26 Nov 2018 11:32:08 +0200 [thread overview]
Message-ID: <f22070d8-e5ca-a8ef-2833-f6bef6801682@ti.com> (raw)
In-Reply-To: <20181121160916.22017-5-sebastian.reichel@collabora.com>
On 21/11/18 18:09, 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 without
> "fb.lockless_register_fb=1" parameter.
>
> This restructures the code, so that the HDMI mode is only configured
> for HDMI output types. The new function also has a safe-guard directly
> before accessing the union, that can be optimized away by the compiler
> when the function is inlined and HDMI type has already been checked.
>
> 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 | 62 +++++++++++++++-----------
> 1 file changed, 37 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c
> index 32bbe3a80e7d..f356821cd078 100644
> --- a/drivers/gpu/drm/omapdrm/omap_encoder.c
> +++ b/drivers/gpu/drm/omapdrm/omap_encoder.c
> @@ -52,17 +52,48 @@ static const struct drm_encoder_funcs omap_encoder_funcs = {
> .destroy = omap_encoder_destroy,
> };
>
> +static void omap_encoder_hdmi_mode_set(struct drm_encoder *encoder,
> + struct drm_display_mode *adjusted_mode)
> +{
> + struct drm_device *dev = encoder->dev;
> + struct omap_encoder *omap_encoder = to_omap_encoder(encoder);
> + struct omap_dss_device *dssdev = omap_encoder->output;
> + struct drm_connector *connector;
> + bool hdmi_mode;
> +
> + hdmi_mode = false;
> + list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
> + if (connector->encoder == encoder) {
> + hdmi_mode = omap_connector_get_hdmi_mode(connector);
> + break;
> + }
> + }
> +
> + /* safe-guard for accessing dssdev->ops->hdmi union */
> + if (dssdev->output_type != OMAP_DISPLAY_TYPE_HDMI)
> + return;
If you safeguard the function, it would make sense to do this at the
very beginning of the function. But to be honest, I think this is just
extra. It's a static function, named "hdmi", so I think we can trust
that we call it correctly.
If you're ok with it, I can pick this patch up and drop the safeguard.
Or you can send a new one.
Tomi
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
next prev parent reply other threads:[~2018-11-26 9:32 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-21 16:09 [PATCHv5 0/6] omapdrm: DSI command mode panel support Sebastian Reichel
2018-11-21 16:09 ` [PATCHv5 1/6] drm/omap: use DRM_DEBUG_DRIVER instead of CORE Sebastian Reichel
2018-11-26 9:25 ` Tomi Valkeinen
2018-11-21 16:09 ` [PATCHv5 2/6] drm/omap: populate DSI platform bus earlier Sebastian Reichel
2018-11-26 9:27 ` Tomi Valkeinen
2018-11-21 16:09 ` [PATCHv5 3/6] drm/omap: don't check dispc timings for DSI Sebastian Reichel
2018-11-21 16:09 ` [PATCHv5 4/6] drm/omap: fix incorrect union usage Sebastian Reichel
2018-11-23 17:33 ` Tony Lindgren
2018-11-26 9:32 ` Tomi Valkeinen [this message]
2018-11-21 16:09 ` [PATCHv5 5/6] drm/omap: add framedone interrupt support Sebastian Reichel
2018-11-21 16:09 ` [PATCHv5 6/6] drm/omap: add support for manually updated displays Sebastian Reichel
2018-11-26 9:34 ` [PATCHv5 0/6] omapdrm: DSI command mode panel support Tomi Valkeinen
2018-11-26 22:45 ` Sebastian Reichel
2019-04-02 15:36 ` Tomi Valkeinen
2019-04-02 15:55 ` Laurent Pinchart
2019-04-03 19:54 ` Sebastian Reichel
2019-04-03 20:13 ` [PATCHv6 0/4] " Sebastian Reichel
2019-04-03 20:13 ` [PATCHv6 1/4] drm/omap: use DRM_DEBUG_DRIVER instead of CORE Sebastian Reichel
2019-04-03 20:13 ` [PATCHv6 2/4] drm/omap: don't check dispc timings for DSI Sebastian Reichel
2019-04-03 20:13 ` [PATCHv6 3/4] drm/omap: add framedone interrupt support Sebastian Reichel
2019-04-03 20:13 ` [PATCHv6 4/4] drm/omap: add support for manually updated displays Sebastian Reichel
2019-04-04 0:11 ` Tony Lindgren
2019-05-22 18:21 ` 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=f22070d8-e5ca-a8ef-2833-f6bef6801682@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
all inboxes | Powered by JetHome®