From: "Michel Dänzer" <michel@daenzer.net>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
linux-samsung-soc@vger.kernel.org,
Benjamin Gaignard <benjamin.gaignard@linaro.org>,
dri-devel@lists.freedesktop.org,
Mark Yao <mark.yao@rock-chips.com>
Subject: Re: [PATCH 08/13] drm/irq: Check for valid VBLANK before dereference
Date: Wed, 17 Dec 2014 12:11:11 +0900 [thread overview]
Message-ID: <5490F44F.30709@daenzer.net> (raw)
In-Reply-To: <1418748815-15434-8-git-send-email-thierry.reding@gmail.com>
On 17.12.2014 01:53, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> When accessing the array of per-CRTC VBLANK structures we must always
> check that the index into the array is valid before dereferencing to
> avoid crashing.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> drivers/gpu/drm/drm_irq.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
> index a24658162284..cb207e047505 100644
> --- a/drivers/gpu/drm/drm_irq.c
> +++ b/drivers/gpu/drm/drm_irq.c
> @@ -1070,10 +1070,10 @@ void drm_vblank_put(struct drm_device *dev, int crtc)
> {
> struct drm_vblank_crtc *vblank = &dev->vblank[crtc];
>
> - if (WARN_ON(atomic_read(&vblank->refcount) == 0))
> + if (WARN_ON(crtc >= dev->num_crtcs))
> return;
>
> - if (WARN_ON(crtc >= dev->num_crtcs))
> + if (WARN_ON(atomic_read(&vblank->refcount) == 0))
> return;
>
> /* Last user schedules interrupt disable */
> @@ -1356,6 +1356,9 @@ void drm_vblank_post_modeset(struct drm_device *dev, int crtc)
> if (!dev->num_crtcs)
> return;
>
> + if (WARN_ON(crtc >= dev->num_crtcs))
> + return;
> +
> if (vblank->inmodeset) {
> spin_lock_irqsave(&dev->vbl_lock, irqflags);
> dev->vblank_disable_allowed = true;
>
It would probably be better to use WARN_ON_ONCE, otherwise any bugs
triggering these might flood dmesg.
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2014-12-17 3:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-16 16:53 [PATCH 01/13] drm/irq: Remove negative CRTC index special-case Thierry Reding
2014-12-16 16:53 ` [PATCH 02/13] drm/bochs: Store correct CRTC index in events Thierry Reding
2014-12-16 16:53 ` [PATCH 03/13] drm/exynos: " Thierry Reding
2014-12-16 16:53 ` [PATCH 04/13] drm/imx: Make pipe number unsigned Thierry Reding
2014-12-16 17:30 ` Philipp Zabel
2014-12-16 16:53 ` [PATCH 05/13] drm/imx: Store correct CRTC index in events Thierry Reding
2014-12-16 17:36 ` Philipp Zabel
2014-12-16 16:53 ` [PATCH 06/13] drm/rockchip: " Thierry Reding
2014-12-16 16:53 ` [PATCH 07/13] drm/sti: " Thierry Reding
2014-12-16 16:53 ` [PATCH 08/13] drm/irq: Check for valid VBLANK before dereference Thierry Reding
2014-12-17 3:11 ` Michel Dänzer [this message]
2014-12-16 16:53 ` [PATCH 09/13] drm/irq: Make pipe unsigned and name consistent Thierry Reding
2014-12-16 17:53 ` Daniel Vetter
2014-12-16 16:53 ` [PATCH 10/13] drm/irq: Add drm_crtc_vblank_count_and_time() Thierry Reding
2014-12-16 16:53 ` [PATCH 11/13] drm/irq: Document return values more consistently Thierry Reding
2014-12-16 18:02 ` Daniel Vetter
2014-12-16 16:53 ` [PATCH 12/13] drm/irq: Expel legacy API Thierry Reding
2014-12-16 17:59 ` Daniel Vetter
2014-12-16 18:00 ` Daniel Vetter
2014-12-16 16:53 ` [PATCH 13/13] drm/irq: Move some prototypes to drm_crtc.h Thierry Reding
-- strict thread matches above, loose matches on Subject: below --
2015-08-12 15:00 [PATCH 01/13] drm/gma500: Sanity-check pipe index Thierry Reding
2015-08-12 15:00 ` [PATCH 08/13] drm/irq: Check for valid VBLANK before dereference Thierry Reding
2015-08-12 15:40 ` Daniel Vetter
2015-08-13 9:20 ` Thierry Reding
2015-08-13 13:05 ` Daniel Vetter
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=5490F44F.30709@daenzer.net \
--to=michel@daenzer.net \
--cc=benjamin.gaignard@linaro.org \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=mark.yao@rock-chips.com \
--cc=thierry.reding@gmail.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