diff options
author | Takashi Iwai <tiwai@suse.de> | 2016-07-25 11:01:14 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2016-07-25 11:01:14 -0400 |
commit | cf81d6b583444cb6f5e656f050e43413b236354e (patch) | |
tree | 646567ef019e0bbc5cc9db0e26c464a9fc239481 /sound/hda | |
parent | 76df52969711ae3725a98f26fbbc6a349803dcbf (diff) | |
parent | 275353bb684ecfeb42f7a353fead81d43a01c519 (diff) |
Merge branch 'for-next' into for-linus
Merged 4.8 changes.
Diffstat (limited to 'sound/hda')
-rw-r--r-- | sound/hda/hdmi_chmap.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/sound/hda/hdmi_chmap.c b/sound/hda/hdmi_chmap.c index c6c75e7e0981..81acc20c2535 100644 --- a/sound/hda/hdmi_chmap.c +++ b/sound/hda/hdmi_chmap.c | |||
@@ -353,7 +353,8 @@ static void hdmi_std_setup_channel_mapping(struct hdac_chmap *chmap, | |||
353 | int hdmi_slot = 0; | 353 | int hdmi_slot = 0; |
354 | /* fill actual channel mappings in ALSA channel (i) order */ | 354 | /* fill actual channel mappings in ALSA channel (i) order */ |
355 | for (i = 0; i < ch_alloc->channels; i++) { | 355 | for (i = 0; i < ch_alloc->channels; i++) { |
356 | while (!ch_alloc->speakers[7 - hdmi_slot] && !WARN_ON(hdmi_slot >= 8)) | 356 | while (!WARN_ON(hdmi_slot >= 8) && |
357 | !ch_alloc->speakers[7 - hdmi_slot]) | ||
357 | hdmi_slot++; /* skip zero slots */ | 358 | hdmi_slot++; /* skip zero slots */ |
358 | 359 | ||
359 | hdmi_channel_mapping[ca][i] = (i << 4) | hdmi_slot++; | 360 | hdmi_channel_mapping[ca][i] = (i << 4) | hdmi_slot++; |
@@ -430,6 +431,12 @@ static int to_cea_slot(int ordered_ca, unsigned char pos) | |||
430 | int mask = snd_hdac_chmap_to_spk_mask(pos); | 431 | int mask = snd_hdac_chmap_to_spk_mask(pos); |
431 | int i; | 432 | int i; |
432 | 433 | ||
434 | /* Add sanity check to pass klockwork check. | ||
435 | * This should never happen. | ||
436 | */ | ||
437 | if (ordered_ca >= ARRAY_SIZE(channel_allocations)) | ||
438 | return -1; | ||
439 | |||
433 | if (mask) { | 440 | if (mask) { |
434 | for (i = 0; i < 8; i++) { | 441 | for (i = 0; i < 8; i++) { |
435 | if (channel_allocations[ordered_ca].speakers[7 - i] == mask) | 442 | if (channel_allocations[ordered_ca].speakers[7 - i] == mask) |
@@ -456,7 +463,15 @@ EXPORT_SYMBOL_GPL(snd_hdac_spk_to_chmap); | |||
456 | /* from CEA slot to ALSA API channel position */ | 463 | /* from CEA slot to ALSA API channel position */ |
457 | static int from_cea_slot(int ordered_ca, unsigned char slot) | 464 | static int from_cea_slot(int ordered_ca, unsigned char slot) |
458 | { | 465 | { |
459 | int mask = channel_allocations[ordered_ca].speakers[7 - slot]; | 466 | int mask; |
467 | |||
468 | /* Add sanity check to pass klockwork check. | ||
469 | * This should never happen. | ||
470 | */ | ||
471 | if (slot >= 8) | ||
472 | return 0; | ||
473 | |||
474 | mask = channel_allocations[ordered_ca].speakers[7 - slot]; | ||
460 | 475 | ||
461 | return snd_hdac_spk_to_chmap(mask); | 476 | return snd_hdac_spk_to_chmap(mask); |
462 | } | 477 | } |
@@ -523,7 +538,8 @@ static void hdmi_setup_fake_chmap(unsigned char *map, int ca) | |||
523 | int ordered_ca = get_channel_allocation_order(ca); | 538 | int ordered_ca = get_channel_allocation_order(ca); |
524 | 539 | ||
525 | for (i = 0; i < 8; i++) { | 540 | for (i = 0; i < 8; i++) { |
526 | if (i < channel_allocations[ordered_ca].channels) | 541 | if (ordered_ca < ARRAY_SIZE(channel_allocations) && |
542 | i < channel_allocations[ordered_ca].channels) | ||
527 | map[i] = from_cea_slot(ordered_ca, hdmi_channel_mapping[ca][i] & 0x0f); | 543 | map[i] = from_cea_slot(ordered_ca, hdmi_channel_mapping[ca][i] & 0x0f); |
528 | else | 544 | else |
529 | map[i] = 0; | 545 | map[i] = 0; |
@@ -551,6 +567,12 @@ int snd_hdac_get_active_channels(int ca) | |||
551 | { | 567 | { |
552 | int ordered_ca = get_channel_allocation_order(ca); | 568 | int ordered_ca = get_channel_allocation_order(ca); |
553 | 569 | ||
570 | /* Add sanity check to pass klockwork check. | ||
571 | * This should never happen. | ||
572 | */ | ||
573 | if (ordered_ca >= ARRAY_SIZE(channel_allocations)) | ||
574 | ordered_ca = 0; | ||
575 | |||
554 | return channel_allocations[ordered_ca].channels; | 576 | return channel_allocations[ordered_ca].channels; |
555 | } | 577 | } |
556 | EXPORT_SYMBOL_GPL(snd_hdac_get_active_channels); | 578 | EXPORT_SYMBOL_GPL(snd_hdac_get_active_channels); |