aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/pci/hda/hda_codec.c22
-rw-r--r--sound/pci/hda/hda_codec.h3
2 files changed, 21 insertions, 4 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 0dbeeaf6113a..e7fb182f90ed 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -465,6 +465,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
465 codec->bus->caddr_tbl[codec->addr] = NULL; 465 codec->bus->caddr_tbl[codec->addr] = NULL;
466 if (codec->patch_ops.free) 466 if (codec->patch_ops.free)
467 codec->patch_ops.free(codec); 467 codec->patch_ops.free(codec);
468 kfree(codec->amp_info);
468 kfree(codec); 469 kfree(codec);
469} 470}
470 471
@@ -586,6 +587,8 @@ static void init_amp_hash(struct hda_codec *codec)
586{ 587{
587 memset(codec->amp_hash, 0xff, sizeof(codec->amp_hash)); 588 memset(codec->amp_hash, 0xff, sizeof(codec->amp_hash));
588 codec->num_amp_entries = 0; 589 codec->num_amp_entries = 0;
590 codec->amp_info_size = 0;
591 codec->amp_info = NULL;
589} 592}
590 593
591/* query the hash. allocate an entry if not found. */ 594/* query the hash. allocate an entry if not found. */
@@ -603,9 +606,22 @@ static struct hda_amp_info *get_alloc_amp_hash(struct hda_codec *codec, u32 key)
603 } 606 }
604 607
605 /* add a new hash entry */ 608 /* add a new hash entry */
606 if (codec->num_amp_entries >= ARRAY_SIZE(codec->amp_info)) { 609 if (codec->num_amp_entries >= codec->amp_info_size) {
607 snd_printk(KERN_ERR "hda_codec: Tooooo many amps!\n"); 610 /* reallocate the array */
608 return NULL; 611 int new_size = codec->amp_info_size + 64;
612 struct hda_amp_info *new_info = kcalloc(new_size, sizeof(struct hda_amp_info),
613 GFP_KERNEL);
614 if (! new_info) {
615 snd_printk(KERN_ERR "hda_codec: can't malloc amp_info\n");
616 return NULL;
617 }
618 if (codec->amp_info) {
619 memcpy(new_info, codec->amp_info,
620 codec->amp_info_size * sizeof(struct hda_amp_info));
621 kfree(codec->amp_info);
622 }
623 codec->amp_info_size = new_size;
624 codec->amp_info = new_info;
609 } 625 }
610 cur = codec->num_amp_entries++; 626 cur = codec->num_amp_entries++;
611 info = &codec->amp_info[cur]; 627 info = &codec->amp_info[cur];
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 1179d6cfa82a..b0123adc569c 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -545,7 +545,8 @@ struct hda_codec {
545 /* hash for amp access */ 545 /* hash for amp access */
546 u16 amp_hash[32]; 546 u16 amp_hash[32];
547 int num_amp_entries; 547 int num_amp_entries;
548 struct hda_amp_info amp_info[128]; /* big enough? */ 548 int amp_info_size;
549 struct hda_amp_info *amp_info;
549 550
550 struct semaphore spdif_mutex; 551 struct semaphore spdif_mutex;
551 unsigned int spdif_status; /* IEC958 status bits */ 552 unsigned int spdif_status; /* IEC958 status bits */