Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/dist/drm/i915 Avoid undefined behavior...



details:   https://anonhg.NetBSD.org/src/rev/77e1d9f76023
branches:  trunk
changeset: 1003816:77e1d9f76023
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Tue Oct 01 18:44:24 2019 +0000

description:
Avoid undefined behavior in g4x_get_stolen_reserved().
The change is the same as newer i915_gem_stolen.c.

diffstat:

 sys/external/bsd/drm2/dist/drm/i915/i915_gem_stolen.c |  17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)

diffs (41 lines):

diff -r 543215c3551b -r 77e1d9f76023 sys/external/bsd/drm2/dist/drm/i915/i915_gem_stolen.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_gem_stolen.c     Tue Oct 01 18:44:22 2019 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_gem_stolen.c     Tue Oct 01 18:44:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i915_gem_stolen.c,v 1.11 2018/09/13 08:25:55 mrg Exp $ */
+/*     $NetBSD: i915_gem_stolen.c,v 1.12 2019/10/01 18:44:24 msaitoh Exp $     */
 
 /*
  * Copyright © 2008-2012 Intel Corporation
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i915_gem_stolen.c,v 1.11 2018/09/13 08:25:55 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i915_gem_stolen.c,v 1.12 2019/10/01 18:44:24 msaitoh Exp $");
 
 #include <linux/printk.h>
 #include <linux/err.h>
@@ -308,18 +308,13 @@
        unsigned long stolen_top = dev_priv->mm.stolen_base +
                dev_priv->gtt.stolen_size;
 
+       if (!(reg_val & G4X_STOLEN_RESERVED_ADDR2_MASK))
+               return;
+
        *base = (reg_val & G4X_STOLEN_RESERVED_ADDR2_MASK) << 16;
-
        WARN_ON((reg_val & G4X_STOLEN_RESERVED_ADDR1_MASK) < *base);
 
-       /* On these platforms, the register doesn't have a size field, so the
-        * size is the distance between the base and the top of the stolen
-        * memory. We also have the genuine case where base is zero and there's
-        * nothing reserved. */
-       if (*base == 0)
-               *size = 0;
-       else
-               *size = stolen_top - *base;
+       *size = stolen_top - *base;
 }
 
 static void gen6_get_stolen_reserved(struct drm_i915_private *dev_priv,



Home | Main Index | Thread Index | Old Index