diff options
author | Alex Deucher <alexdeucher@gmail.com> | 2009-10-28 00:51:20 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-10-28 01:30:03 -0400 |
commit | d11aa88b33b071d55181a7a482b9e7494888c10e (patch) | |
tree | 8b95c80e299383c41b7ede5485ebf45b25b6e5ed /drivers/gpu | |
parent | a2d49ae7df5b96fba3c63710df61412587fc6a24 (diff) |
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: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/radeon/atombios_crtc.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c index 8516e1b2329a..c15287a590ff 100644 --- a/drivers/gpu/drm/radeon/atombios_crtc.c +++ b/drivers/gpu/drm/radeon/atombios_crtc.c | |||
@@ -368,14 +368,17 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable) | |||
368 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { | 368 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
369 | if (encoder->crtc == crtc) { | 369 | if (encoder->crtc == crtc) { |
370 | radeon_encoder = to_radeon_encoder(encoder); | 370 | radeon_encoder = to_radeon_encoder(encoder); |
371 | dig = radeon_encoder->enc_priv; | ||
372 | /* only enable spread spectrum on LVDS */ | 371 | /* only enable spread spectrum on LVDS */ |
373 | if (dig && dig->ss) { | 372 | if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { |
374 | percentage = dig->ss->percentage; | 373 | dig = radeon_encoder->enc_priv; |
375 | type = dig->ss->type; | 374 | if (dig && dig->ss) { |
376 | step = dig->ss->step; | 375 | percentage = dig->ss->percentage; |
377 | delay = dig->ss->delay; | 376 | type = dig->ss->type; |
378 | range = dig->ss->range; | 377 | step = dig->ss->step; |
378 | delay = dig->ss->delay; | ||
379 | range = dig->ss->range; | ||
380 | } else if (enable) | ||
381 | return; | ||
379 | } else if (enable) | 382 | } else if (enable) |
380 | return; | 383 | return; |
381 | break; | 384 | break; |
@@ -387,7 +390,7 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable) | |||
387 | 390 | ||
388 | if (ASIC_IS_AVIVO(rdev)) { | 391 | if (ASIC_IS_AVIVO(rdev)) { |
389 | memset(&args, 0, sizeof(args)); | 392 | memset(&args, 0, sizeof(args)); |
390 | args.usSpreadSpectrumPercentage = percentage; | 393 | args.usSpreadSpectrumPercentage = cpu_to_le16(percentage); |
391 | args.ucSpreadSpectrumType = type; | 394 | args.ucSpreadSpectrumType = type; |
392 | args.ucSpreadSpectrumStep = step; | 395 | args.ucSpreadSpectrumStep = step; |
393 | args.ucSpreadSpectrumDelay = delay; | 396 | args.ucSpreadSpectrumDelay = delay; |
@@ -397,7 +400,7 @@ static void atombios_set_ss(struct drm_crtc *crtc, int enable) | |||
397 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); | 400 | atom_execute_table(rdev->mode_info.atom_context, index, (uint32_t *)&args); |
398 | } else { | 401 | } else { |
399 | memset(&legacy_args, 0, sizeof(legacy_args)); | 402 | memset(&legacy_args, 0, sizeof(legacy_args)); |
400 | legacy_args.usSpreadSpectrumPercentage = percentage; | 403 | legacy_args.usSpreadSpectrumPercentage = cpu_to_le16(percentage); |
401 | legacy_args.ucSpreadSpectrumType = type; | 404 | legacy_args.ucSpreadSpectrumType = type; |
402 | legacy_args.ucSpreadSpectrumStepSize_Delay = (step & 3) << 2; | 405 | legacy_args.ucSpreadSpectrumStepSize_Delay = (step & 3) << 2; |
403 | legacy_args.ucSpreadSpectrumStepSize_Delay |= (delay & 7) << 4; | 406 | legacy_args.ucSpreadSpectrumStepSize_Delay |= (delay & 7) << 4; |