Commit d11aa88b authored by Alex Deucher's avatar Alex Deucher Committed by Dave Airlie

drm/radeon/kms/atom: fix potential oops in spread spectrum code

Make sure we have an LVDS encoder before casting enc_priv.

[airlied: also fix two missing cpu_to_le16 casts we noticed on irc]
Signed-off-by: default avatarAlex Deucher <alexdeucher@gmail.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent a2d49ae7
...@@ -368,14 +368,17 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable) ...@@ -368,14 +368,17 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable)
list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
if (encoder->crtc == crtc) { if (encoder->crtc == crtc) {
radeon_encoder = to_radeon_encoder(encoder); radeon_encoder = to_radeon_encoder(encoder);
dig = radeon_encoder->enc_priv;
/* only enable spread spectrum on LVDS */ /* only enable spread spectrum on LVDS */
if (dig && dig->ss) { if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
percentage = dig->ss->percentage; dig = radeon_encoder->enc_priv;
type = dig->ss->type; if (dig && dig->ss) {
step = dig->ss->step; percentage = dig->ss->percentage;
delay = dig->ss->delay; type = dig->ss->type;
range = dig->ss->range; step = dig->ss->step;
delay = dig->ss->delay;
range = dig->ss->range;
} else if (enable)
return;
} else if (enable) } else if (enable)
return; return;
break; break;
...@@ -387,7 +390,7 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable) ...@@ -387,7 +390,7 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable)
if (ASIC_IS_AVIVO(rdev)) { if (ASIC_IS_AVIVO(rdev)) {
memset(&args, 0, sizeof(args)); memset(&args, 0, sizeof(args));
args.usSpreadSpectrumPercentage = percentage; args.usSpreadSpectrumPercentage = cpu_to_le16(percentage);
args.ucSpreadSpectrumType = type; args.ucSpreadSpectrumType = type;
args.ucSpreadSpectrumStep = step; args.ucSpreadSpectrumStep = step;
args.ucSpreadSpectrumDelay = delay; args.ucSpreadSpectrumDelay = delay;
...@@ -397,7 +400,7 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable) ...@@ -397,7 +400,7 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable)
atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args);
} else { } else {
memset(&legacy_args, 0, sizeof(legacy_args)); memset(&legacy_args, 0, sizeof(legacy_args));
legacy_args.usSpreadSpectrumPercentage = percentage; legacy_args.usSpreadSpectrumPercentage = cpu_to_le16(percentage);
legacy_args.ucSpreadSpectrumType = type; legacy_args.ucSpreadSpectrumType = type;
legacy_args.ucSpreadSpectrumStepSize_Delay = (step & 3) << 2; legacy_args.ucSpreadSpectrumStepSize_Delay = (step & 3) << 2;
legacy_args.ucSpreadSpectrumStepSize_Delay |= (delay & 7) << 4; legacy_args.ucSpreadSpectrumStepSize_Delay |= (delay & 7) << 4;
......
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