Commit 7304b981 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/edid: Check the number of detailed timing descriptors in the CEA ext block

CEA-861 says :
"d = offset for the byte following the reserved data block.
 If no data is provided in the reserved data block, then d=4.
 If no DTDs are provided, then d=0."

So let's not look for DTDs when d==0. In fact let's just make that
<4 since those values would just mean that he DTDs overlap the block
header. And let's also check that d isn't so big as to declare
the descriptors to live past the block end, although the code
does already survive that case as we'd just end up with a negative
number of descriptors and the loop would not do anything.

Cc: Allen Chen <allen.chen@ite.com.tw>
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200124200231.10517-1-ville.syrjala@linux.intel.comAcked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarUma Shankar <uma.shankar@intel.com>
parent 7f97d3e8
...@@ -2217,10 +2217,13 @@ typedef void detailed_cb(struct detailed_timing *timing, void *closure); ...@@ -2217,10 +2217,13 @@ typedef void detailed_cb(struct detailed_timing *timing, void *closure);
static void static void
cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure) cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
{ {
int i, n = 0; int i, n;
u8 d = ext[0x02]; u8 d = ext[0x02];
u8 *det_base = ext + d; u8 *det_base = ext + d;
if (d < 4 || d > 127)
return;
n = (127 - d) / 18; n = (127 - d) / 18;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
cb((struct detailed_timing *)(det_base + 18 * i), closure); cb((struct detailed_timing *)(det_base + 18 * i), closure);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment