Commit fa99239c authored by Roel Kluin's avatar Roel Kluin Committed by Dave Airlie

drm/radeon: Read buffer overflow

Check whether index is within bounds before grabbing the element.
Signed-off-by: default avatarRoel Kluin <roel.kluin@gmail.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent fee280d3
...@@ -722,13 +722,14 @@ int r100_cs_packet_parse(struct radeon_cs_parser *p, ...@@ -722,13 +722,14 @@ int r100_cs_packet_parse(struct radeon_cs_parser *p,
unsigned idx) unsigned idx)
{ {
struct radeon_cs_chunk *ib_chunk = &p->chunks[p->chunk_ib_idx]; struct radeon_cs_chunk *ib_chunk = &p->chunks[p->chunk_ib_idx];
uint32_t header = ib_chunk->kdata[idx]; uint32_t header;
if (idx >= ib_chunk->length_dw) { if (idx >= ib_chunk->length_dw) {
DRM_ERROR("Can not parse packet at %d after CS end %d !\n", DRM_ERROR("Can not parse packet at %d after CS end %d !\n",
idx, ib_chunk->length_dw); idx, ib_chunk->length_dw);
return -EINVAL; return -EINVAL;
} }
header = ib_chunk->kdata[idx];
pkt->idx = idx; pkt->idx = idx;
pkt->type = CP_PACKET_GET_TYPE(header); pkt->type = CP_PACKET_GET_TYPE(header);
pkt->count = CP_PACKET_GET_COUNT(header); pkt->count = CP_PACKET_GET_COUNT(header);
......
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