mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
drm/radeon: more strictly validate the UVD codec
MPEG 2/4 are only supported since UVD3. Signed-off-by: Christian König <christian.koenig@amd.com> CC: stable@vger.kernel.org Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
a1b403da70
commit
d52cdfa4a0
1 changed files with 31 additions and 2 deletions
|
@ -396,6 +396,29 @@ static int radeon_uvd_cs_msg_decode(uint32_t *msg, unsigned buf_sizes[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int radeon_uvd_validate_codec(struct radeon_cs_parser *p,
|
||||||
|
unsigned stream_type)
|
||||||
|
{
|
||||||
|
switch (stream_type) {
|
||||||
|
case 0: /* H264 */
|
||||||
|
case 1: /* VC1 */
|
||||||
|
/* always supported */
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case 3: /* MPEG2 */
|
||||||
|
case 4: /* MPEG4 */
|
||||||
|
/* only since UVD 3 */
|
||||||
|
if (p->rdev->family >= CHIP_PALM)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* fall through */
|
||||||
|
default:
|
||||||
|
DRM_ERROR("UVD codec not supported by hardware %d!\n",
|
||||||
|
stream_type);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
|
static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
|
||||||
unsigned offset, unsigned buf_sizes[])
|
unsigned offset, unsigned buf_sizes[])
|
||||||
{
|
{
|
||||||
|
@ -440,7 +463,11 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
|
||||||
case 0:
|
case 0:
|
||||||
/* it's a create msg, calc image size (width * height) */
|
/* it's a create msg, calc image size (width * height) */
|
||||||
img_size = msg[7] * msg[8];
|
img_size = msg[7] * msg[8];
|
||||||
|
|
||||||
|
r = radeon_uvd_validate_codec(p, msg[4]);
|
||||||
radeon_bo_kunmap(bo);
|
radeon_bo_kunmap(bo);
|
||||||
|
if (r)
|
||||||
|
return r;
|
||||||
|
|
||||||
/* try to alloc a new handle */
|
/* try to alloc a new handle */
|
||||||
for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
|
for (i = 0; i < RADEON_MAX_UVD_HANDLES; ++i) {
|
||||||
|
@ -460,8 +487,10 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
/* it's a decode msg, calc buffer sizes */
|
/* it's a decode msg, validate codec and calc buffer sizes */
|
||||||
r = radeon_uvd_cs_msg_decode(msg, buf_sizes);
|
r = radeon_uvd_validate_codec(p, msg[4]);
|
||||||
|
if (!r)
|
||||||
|
r = radeon_uvd_cs_msg_decode(msg, buf_sizes);
|
||||||
radeon_bo_kunmap(bo);
|
radeon_bo_kunmap(bo);
|
||||||
if (r)
|
if (r)
|
||||||
return r;
|
return r;
|
||||||
|
|
Loading…
Add table
Reference in a new issue