drm/radeon/dce6/audio: make sure pin is valid before accessing it
authorAlex Deucher <alexander.deucher@amd.com>
Tue, 3 Sep 2013 18:03:21 +0000 (14:03 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 11 Sep 2013 15:44:25 +0000 (11:44 -0400)
Make sure the audio pin is valid before accessing its members.

Noticed by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/dce6_afmt.c

index 8953255e894b2524e020fd10b99898eceedfd4c9..3853dda797dd0d882fbbd4ce5a764c46c18e1861 100644 (file)
@@ -86,12 +86,12 @@ void dce6_afmt_select_pin(struct drm_encoder *encoder)
        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 id = dig->afmt->pin->id;
 
        if (!dig->afmt->pin)
                return;
 
-       WREG32(AFMT_AUDIO_SRC_CONTROL + offset, AFMT_AUDIO_SRC_SELECT(id));
+       WREG32(AFMT_AUDIO_SRC_CONTROL + offset,
+              AFMT_AUDIO_SRC_SELECT(dig->afmt->pin->id));
 }
 
 void dce6_afmt_write_speaker_allocation(struct drm_encoder *encoder)