Skip to content

Commit

Permalink
drm/radeon: fix null pointer dereference in dce6+ audio code
Browse files Browse the repository at this point in the history
Don't crash if the encoder does not have an afmt struct.

bug:
https://bugs.freedesktop.org/show_bug.cgi?id=72283

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
  • Loading branch information
Alex Deucher committed Dec 5, 2013
1 parent 0ca223b commit 53dc0b0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/gpu/drm/radeon/dce6_afmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,13 @@ void dce6_afmt_select_pin(struct drm_encoder *encoder)
struct radeon_device *rdev = encoder->dev->dev_private;
struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
u32 offset = dig->afmt->offset;
u32 offset;

if (!dig->afmt->pin)
if (!dig || !dig->afmt || !dig->afmt->pin)
return;

offset = dig->afmt->offset;

WREG32(AFMT_AUDIO_SRC_CONTROL + offset,
AFMT_AUDIO_SRC_SELECT(dig->afmt->pin->id));
}
Expand All @@ -112,7 +114,7 @@ void dce6_afmt_write_latency_fields(struct drm_encoder *encoder,
struct radeon_connector *radeon_connector = NULL;
u32 tmp = 0, offset;

if (!dig->afmt->pin)
if (!dig || !dig->afmt || !dig->afmt->pin)
return;

offset = dig->afmt->pin->offset;
Expand Down Expand Up @@ -156,7 +158,7 @@ void dce6_afmt_write_speaker_allocation(struct drm_encoder *encoder)
u8 *sadb;
int sad_count;

if (!dig->afmt->pin)
if (!dig || !dig->afmt || !dig->afmt->pin)
return;

offset = dig->afmt->pin->offset;
Expand Down Expand Up @@ -217,7 +219,7 @@ void dce6_afmt_write_sad_regs(struct drm_encoder *encoder)
{ AZ_F0_CODEC_PIN_CONTROL_AUDIO_DESCRIPTOR13, HDMI_AUDIO_CODING_TYPE_WMA_PRO },
};

if (!dig->afmt->pin)
if (!dig || !dig->afmt || !dig->afmt->pin)
return;

offset = dig->afmt->pin->offset;
Expand Down

0 comments on commit 53dc0b0

Please sign in to comment.