Skip to contentSkip to conversation

drm/i915/audio: fix check for av_enc_map overflow

PATCH In review Jani Nikula 4 participants 6 messages Feb 14, 2018 – Feb 15, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915/audio: fix check for av_enc_map overflow

Turns out -1 >= ARRAY_SIZE() is always true. Move the bounds check where we know pipe >= 0 and next to the array indexing where it makes most sense.

Fixes 9965db26ac05 ("drm/i915: Check for fused or unused pipes")
Fixes 0b7029b7e43f ("drm/i915: Check for fused or unused pipes")
Cc <[email protected]> # v4.10+
Cc Mika Kahola <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/intel_audio.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_audio.c +3 -3
index ff455c724775..709d6ca68074 100644
@@ -779,11 +779,11 @@ static struct intel_encoder *get_saved_enc(struct drm_i915_private *dev_priv,
 {
 	struct intel_encoder *encoder;
 
-	if (WARN_ON(pipe >= ARRAY_SIZE(dev_priv->av_enc_map)))
-		return NULL;
-
 	/* MST */
 	if (pipe >= 0) {
+		if (WARN_ON(pipe >= ARRAY_SIZE(dev_priv->av_enc_map)))
+			return NULL;
+
 		encoder = dev_priv->av_enc_map[pipe];
 		/*
 		 * when bootup, audio driver may not know it is
Signature · 1 line
2.11.0
#1 lore raw

✓ Fi.CI.BAT: success for drm/i915/audio: fix check for av_enc_map overflow

== Series Details ==

== Series Details ==

Series: drm/i915/audio: fix check for av_enc_map overflow
URL : https://patchwork.freedesktop.org/series/38271/
State : success

== Summary ==

Series 38271v1 drm/i915/audio: fix check for av_enc_map overflow
https://patchwork.freedesktop.org/api/1.0/series/38271/revisions/1/mbox/

Test debugfs_test:

        Subgroup read_all_entries:
                pass       -> INCOMPLETE (fi-snb-2520m) fdo#103713

fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:423s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:424s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:374s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:492s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:287s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:485s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:470s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:456s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:569s
fi-cnl-y3        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:577s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:410s
fi-gdg-551       total:288  pass:179  dwarn:0   dfail:0   fail:1   skip:108 time:282s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:510s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:389s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:408s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:460s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:412s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:455s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:495s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:502s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:588s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:423s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:504s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:524s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:493s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:480s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:413s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:431s
fi-snb-2520m     total:3    pass:2    dwarn:0   dfail:0   fail:0   skip:0  
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:399s
Blacklisted hosts:
fi-glk-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:470s
fi-kbl-7567u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:453s

fi-bxt-dsi failed to collect. IGT log at Patchwork_8027/fi-bxt-dsi/run0.log

5ad7866768dcc5d993f1bba687a80fced1070635 drm-tip: 2018y-02m-14d-15h-14m-50s UTC integration manifest 2127138f460a drm/i915/audio: fix check for av_enc_map overflow

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8027/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 1/1
#2 lore raw
In reply to Jani Nikula

z

Quoted 4 lines · Jani Nikula

Turns out -1 >= ARRAY_SIZE() is always true. Move the bounds check where we know pipe >= 0 and next to the array indexing where it makes most sense.

Quoted 9 lines
Fixes 9965db26ac05 ("drm/i915: Check for fused or unused pipes")
Fixes 0b7029b7e43f ("drm/i915: Check for fused or unused pipes")
Cc <[email protected]> # v4.10+
Cc Mika Kahola <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Quoted 13 lines
---
 drivers/gpu/drm/i915/intel_audio.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_audio.c +0 -1
index ff455c724775..709d6ca68074 100644
@@ -779,11 +779,11 @@ static struct intel_encoder *get_saved_enc(struct drm_i915_private *dev_priv,
 {
 	struct intel_encoder *encoder;
 
-	if (WARN_ON(pipe >= ARRAY_SIZE(dev_priv->av_enc_map)))

drivers/gpu/drm/i915/intel_audio.c static struct intel_encoder *get_saved_enc(struct drm_i915_private *dev_priv, · line 789

Quoted 10 lines
drivers/gpu/drm/i915/intel_audio.c +3 -2
-		return NULL;
-
 	/* MST */
 	if (pipe >= 0) {
+		if (WARN_ON(pipe >= ARRAY_SIZE(dev_priv->av_enc_map)))
+			return NULL;
+
 		encoder = dev_priv->av_enc_map[pipe];
 		/*
 		 * when bootup, audio driver may not know it is

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

✓ Fi.CI.IGT: success for drm/i915/audio: fix check for av_enc_map overflow

In reply to Jani Nikula
== Series Details ==

== Series Details ==

Series: drm/i915/audio: fix check for av_enc_map overflow
URL : https://patchwork.freedesktop.org/series/38271/
State : success

== Summary ==

Test kms_flip:

        Subgroup 2x-flip-vs-expired-vblank-interruptible:
                pass       -> FAIL       (shard-hsw) fdo#102887
Test kms_sysfs_edid_timing:
                pass       -> WARN       (shard-apl) fdo#100047
Test perf:
        Subgroup buffer-fill:
                pass       -> FAIL       (shard-apl) fdo#103755
        Subgroup oa-exponents:
                pass       -> FAIL       (shard-hsw) fdo#102254 +1
Test gem_softpin:
        Subgroup noreloc-s3:
                incomplete -> PASS       (shard-hsw) fdo#103540
Test kms_vblank:
        Subgroup crtc-id:
                skip       -> PASS       (shard-snb)
        Subgroup pipe-a-ts-continuation-modeset:
                skip       -> PASS       (shard-snb)

fdo#102887 https://bugs.freedesktop.org/show_bug.cgi?id=102887
fdo#100047 https://bugs.freedesktop.org/show_bug.cgi?id=100047
fdo#103755 https://bugs.freedesktop.org/show_bug.cgi?id=103755
fdo#102254 https://bugs.freedesktop.org/show_bug.cgi?id=102254
fdo#103540 https://bugs.freedesktop.org/show_bug.cgi?id=103540

shard-apl        total:3346 pass:1736 dwarn:1   dfail:0   fail:21  skip:1586 time:13984s
shard-hsw        total:3427 pass:1756 dwarn:1   dfail:0   fail:13  skip:1656 time:14646s
shard-snb        total:3427 pass:1349 dwarn:1   dfail:0   fail:10  skip:2067 time:7629s

Blacklisted hosts:
shard-kbl total:3427 pass:1908 dwarn:1 dfail:0 fail:20 skip:1498 time:11133s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8027/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reviewed-by on v1 1/1
#4 lore raw
In reply to Jani Nikula
Quoted 5 lines · Jani Nikula

Turns out -1 >= ARRAY_SIZE() is always true. Move the bounds check where
we know pipe >= 0 and next to the array indexing where it makes most sense.

Quoted 8 lines
Fixes 9965db26ac05 ("drm/i915: Check for fused or unused pipes")
Fixes 0b7029b7e43f ("drm/i915: Check for fused or unused pipes")
Cc <[email protected]> # v4.10+
Cc Mika Kahola <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Quoted 27 lines

---
 drivers/gpu/drm/i915/intel_audio.c | 6 +++---

 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_audio.c +0 -0
index ff455c724775..709d6ca68074 100644
@@ -779,11 +779,11 @@ static struct intel_encoder
 *get_saved_enc(struct drm_i915_private *dev_priv,
  {
  	struct intel_encoder *encoder;

drivers/gpu/drm/i915/intel_audio.c +0 -3
-	if (WARN_ON(pipe >= ARRAY_SIZE(dev_priv->av_enc_map)))
-		return NULL;
-

  /* MST */
  if (pipe >= 0) {

drivers/gpu/drm/i915/intel_audio.c +1 -0
+		if (WARN_ON(pipe >= ARRAY_SIZE(dev_priv-
Quoted 1 line

av_enc_map)))

drivers/gpu/drm/i915/intel_audio.c +2 -0
+			return NULL;
+

  encoder = dev_priv->av_enc_map[pipe]; /*
   * when bootup, audio driver may not know it is

Signature · 6 lines
Mika Kahola - Intel OTC

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
author Applied
#5 lore raw
Quoted 15 lines · Mika Kahola
Quoted 5 lines · Jani Nikula

Turns out -1 >= ARRAY_SIZE() is always true. Move the bounds check where
we know pipe >= 0 and next to the array indexing where it makes most sense.

Quoted 8 lines
Fixes 9965db26ac05 ("drm/i915: Check for fused or unused pipes")
Fixes 0b7029b7e43f ("drm/i915: Check for fused or unused pipes")
Cc <[email protected]> # v4.10+
Cc Mika Kahola <[email protected]>
Cc Rodrigo Vivi <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Joonas Lahtinen <[email protected]>
Quoted 1 line

Pushed to dinq, thanks for the reviews.

BR,
Jani.

Quoted 28 lines
Quoted 28 lines

---
 drivers/gpu/drm/i915/intel_audio.c | 6 +++---

 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/intel_audio.c +0 -0
index ff455c724775..709d6ca68074 100644
@@ -779,11 +779,11 @@ static struct intel_encoder
 *get_saved_enc(struct drm_i915_private *dev_priv,
  {
  	struct intel_encoder *encoder;

drivers/gpu/drm/i915/intel_audio.c +0 -3
-	if (WARN_ON(pipe >= ARRAY_SIZE(dev_priv->av_enc_map)))
-		return NULL;
-

  /* MST */
  if (pipe >= 0) {

drivers/gpu/drm/i915/intel_audio.c +1 -0
+		if (WARN_ON(pipe >= ARRAY_SIZE(dev_priv-
Quoted 1 line

av_enc_map)))

drivers/gpu/drm/i915/intel_audio.c +2 -0
+			return NULL;
+

  encoder = dev_priv->av_enc_map[pipe]; /*
   * when bootup, audio driver may not know it is

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx