mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	dri-devel@lists.freedesktop.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/cirrus: Fix NULL pointer dereference when registering the fbdev
Date: Mon, 08 Aug 2016 22:36:13 -0500	[thread overview]
Message-ID: <87a8gmliky.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <1470701778-20839-1-git-send-email-boris.brezillon@free-electrons.com> (Boris Brezillon's message of "Tue, 9 Aug 2016 02:16:18 +0200")

Boris Brezillon <boris.brezillon@free-electrons.com> writes:

> cirrus_modeset_init() is initializing/registering the emulated fbdev
> and, since commit c61b93fe51b1 ("drm/atomic: Fix remaining places where
> !funcs->best_encoder is valid"), DRM internals can access/test some of
> the fields in mode_config->funcs as part of the fbdev registration
> process.
> Make sure dev->mode_config.funcs is properly set to avoid dereferencing
> a NULL pointer.

That fixes the issues I am seeing.

Tested-by: "Eric W. Biederman" <ebiederm@xmission.com>

> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> Fixes: c61b93fe51b1 ("drm/atomic: Fix remaining places where !funcs->best_encoder is valid")
> ---
> Hi Dave,
>
> As discussed on IRC, I'm sending this patch in a proper format. That's
> probably better to wait for Eric's feeback before applying it though.

It is weird I didn't see either of your email messages directly only
through lkml.  Weird.

> Regards,
>
> Boris
> ---
>  drivers/gpu/drm/cirrus/cirrus_main.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c b/drivers/gpu/drm/cirrus/cirrus_main.c
> index 80446e2d3ab6..76bcb43e7c06 100644
> --- a/drivers/gpu/drm/cirrus/cirrus_main.c
> +++ b/drivers/gpu/drm/cirrus/cirrus_main.c
> @@ -185,14 +185,23 @@ int cirrus_driver_load(struct drm_device *dev, unsigned long flags)
>  		goto out;
>  	}
>  
> +	/*
> +	 * cirrus_modeset_init() is initializing/registering the emulated fbdev
> +	 * and DRM internals can access/test some of the fields in
> +	 * mode_config->funcs as part of the fbdev registration process.
> +	 * Make sure dev->mode_config.funcs is properly set to avoid
> +	 * dereferencing a NULL pointer.
> +	 * FIXME: mode_config.funcs assignment should probably be done in
> +	 * cirrus_modeset_init() (that's a common pattern seen in other DRM
> +	 * drivers).
> +	 */
> +	dev->mode_config.funcs = &cirrus_mode_funcs;
>  	r = cirrus_modeset_init(cdev);
>  	if (r) {
>  		dev_err(&dev->pdev->dev, "Fatal error during modeset init: %d\n", r);
>  		goto out;
>  	}
>  
> -	dev->mode_config.funcs = (void *)&cirrus_mode_funcs;
> -
>  	return 0;
>  out:
>  	cirrus_driver_unload(dev);

  reply	other threads:[~2016-08-09  3:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-08  1:46 Linux 4.8-rc1 Linus Torvalds
     [not found] ` <87k2frovps.fsf@x220.int.ebiederm.org>
2016-08-08 21:19   ` Linux 4.8-rc1 Cirrus QEMU crashes on boot Linus Torvalds
2016-08-08 21:59     ` David Airlie
2016-08-09  0:16       ` [PATCH] drm/cirrus: Fix NULL pointer dereference when registering the fbdev Boris Brezillon
2016-08-09  3:36         ` Eric W. Biederman [this message]
2016-08-09  8:06           ` Boris Brezillon
2016-08-08 22:03     ` Linux 4.8-rc1 Cirrus QEMU crashes on boot Boris Brezillon
2016-08-09  0:19 ` linux-next: stats (Was: Linux 4.8-rc1) Stephen Rothwell

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=87a8gmliky.fsf@x220.int.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=airlied@linux.ie \
    --cc=boris.brezillon@free-electrons.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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

Powered by JetHome