Merge tag 'overflow-v4.18-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull more overflow updates from Kees Cook: "The rest of the overflow changes for v4.18-rc1. This includes the explicit overflow fixes from Silvio, further struct_size() conversions from Matthew, and a bug fix from Dan. But the bulk of it is the treewide conversions to use either the 2-factor argument allocators (e.g. kmalloc(a * b, ...) into kmalloc_array(a, b, ...) or the array_size() macros (e.g. vmalloc(a * b) into vmalloc(array_size(a, b)). Coccinelle was fighting me on several fronts, so I've done a bunch of manual whitespace updates in the patches as well. Summary: - Error path bug fix for overflow tests (Dan) - Additional struct_size() conversions (Matthew, Kees) - Explicitly reported overflow fixes (Silvio, Kees) - Add missing kvcalloc() function (Kees) - Treewide conversions of allocators to use either 2-factor argument variant when available, or array_size() and array3_size() as needed (Kees)" * tag 'overflow-v4.18-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (26 commits) treewide: Use array_size in f2fs_kvzalloc() treewide: Use array_size() in f2fs_kzalloc() treewide: Use array_size() in f2fs_kmalloc() treewide: Use array_size() in sock_kmalloc() treewide: Use array_size() in kvzalloc_node() treewide: Use array_size() in vzalloc_node() treewide: Use array_size() in vzalloc() treewide: Use array_size() in vmalloc() treewide: devm_kzalloc() -> devm_kcalloc() treewide: devm_kmalloc() -> devm_kmalloc_array() treewide: kvzalloc() -> kvcalloc() treewide: kvmalloc() -> kvmalloc_array() treewide: kzalloc_node() -> kcalloc_node() treewide: kzalloc() -> kcalloc() treewide: kmalloc() -> kmalloc_array() mm: Introduce kvcalloc() video: uvesafb: Fix integer overflow in allocation UBIFS: Fix potential integer overflow in allocation leds: Use struct_size() in allocation Convert intel uncore to struct_size ...
This commit is contained in:
@@ -426,7 +426,7 @@ static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream,
|
||||
get_user(frames, &data32->frames))
|
||||
return -EFAULT;
|
||||
bufptr = compat_ptr(buf);
|
||||
bufs = kmalloc(sizeof(void __user *) * ch, GFP_KERNEL);
|
||||
bufs = kmalloc_array(ch, sizeof(void __user *), GFP_KERNEL);
|
||||
if (bufs == NULL)
|
||||
return -ENOMEM;
|
||||
for (i = 0; i < ch; i++) {
|
||||
|
@@ -3072,7 +3072,7 @@ static ssize_t snd_pcm_readv(struct kiocb *iocb, struct iov_iter *to)
|
||||
if (!frame_aligned(runtime, to->iov->iov_len))
|
||||
return -EINVAL;
|
||||
frames = bytes_to_samples(runtime, to->iov->iov_len);
|
||||
bufs = kmalloc(sizeof(void *) * to->nr_segs, GFP_KERNEL);
|
||||
bufs = kmalloc_array(to->nr_segs, sizeof(void *), GFP_KERNEL);
|
||||
if (bufs == NULL)
|
||||
return -ENOMEM;
|
||||
for (i = 0; i < to->nr_segs; ++i)
|
||||
@@ -3107,7 +3107,7 @@ static ssize_t snd_pcm_writev(struct kiocb *iocb, struct iov_iter *from)
|
||||
!frame_aligned(runtime, from->iov->iov_len))
|
||||
return -EINVAL;
|
||||
frames = bytes_to_samples(runtime, from->iov->iov_len);
|
||||
bufs = kmalloc(sizeof(void *) * from->nr_segs, GFP_KERNEL);
|
||||
bufs = kmalloc_array(from->nr_segs, sizeof(void *), GFP_KERNEL);
|
||||
if (bufs == NULL)
|
||||
return -ENOMEM;
|
||||
for (i = 0; i < from->nr_segs; ++i)
|
||||
|
@@ -389,7 +389,8 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)
|
||||
if (snd_BUG_ON(!pool))
|
||||
return -EINVAL;
|
||||
|
||||
cellptr = vmalloc(sizeof(struct snd_seq_event_cell) * pool->size);
|
||||
cellptr = vmalloc(array_size(sizeof(struct snd_seq_event_cell),
|
||||
pool->size));
|
||||
if (!cellptr)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -657,7 +657,7 @@ static struct snd_midi_channel *snd_midi_channel_init_set(int n)
|
||||
struct snd_midi_channel *chan;
|
||||
int i;
|
||||
|
||||
chan = kmalloc(n * sizeof(struct snd_midi_channel), GFP_KERNEL);
|
||||
chan = kmalloc_array(n, sizeof(struct snd_midi_channel), GFP_KERNEL);
|
||||
if (chan) {
|
||||
for (i = 0; i < n; i++)
|
||||
snd_midi_channel_init(chan+i, i);
|
||||
|
@@ -147,7 +147,7 @@ static int ff400_switch_fetching_mode(struct snd_ff *ff, bool enable)
|
||||
__le32 *reg;
|
||||
int i;
|
||||
|
||||
reg = kzalloc(sizeof(__le32) * 18, GFP_KERNEL);
|
||||
reg = kcalloc(18, sizeof(__le32), GFP_KERNEL);
|
||||
if (reg == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -27,7 +27,7 @@ int iso_packets_buffer_init(struct iso_packets_buffer *b, struct fw_unit *unit,
|
||||
void *p;
|
||||
int err;
|
||||
|
||||
b->packets = kmalloc(count * sizeof(*b->packets), GFP_KERNEL);
|
||||
b->packets = kmalloc_array(count, sizeof(*b->packets), GFP_KERNEL);
|
||||
if (!b->packets) {
|
||||
err = -ENOMEM;
|
||||
goto error;
|
||||
|
@@ -420,7 +420,7 @@ static int sq_allocate_buffers(struct sound_queue *sq, int num, int size)
|
||||
return 0;
|
||||
sq->numBufs = num;
|
||||
sq->bufSize = size;
|
||||
sq->buffers = kmalloc (num * sizeof(char *), GFP_KERNEL);
|
||||
sq->buffers = kmalloc_array (num, sizeof(char *), GFP_KERNEL);
|
||||
if (!sq->buffers)
|
||||
return -ENOMEM;
|
||||
for (i = 0; i < num; i++) {
|
||||
|
@@ -460,7 +460,7 @@ static int load_firmware(struct snd_cs46xx *chip,
|
||||
entry->size = le32_to_cpu(fwdat[fwlen++]);
|
||||
if (fwlen + entry->size > fwsize)
|
||||
goto error_inval;
|
||||
entry->data = kmalloc(entry->size * 4, GFP_KERNEL);
|
||||
entry->data = kmalloc_array(entry->size, 4, GFP_KERNEL);
|
||||
if (!entry->data)
|
||||
goto error;
|
||||
memcpy_le32(entry->data, &fwdat[fwlen], entry->size * 4);
|
||||
@@ -4036,8 +4036,9 @@ int snd_cs46xx_create(struct snd_card *card,
|
||||
snd_cs46xx_proc_init(card, chip);
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
chip->saved_regs = kmalloc(sizeof(*chip->saved_regs) *
|
||||
ARRAY_SIZE(saved_regs), GFP_KERNEL);
|
||||
chip->saved_regs = kmalloc_array(ARRAY_SIZE(saved_regs),
|
||||
sizeof(*chip->saved_regs),
|
||||
GFP_KERNEL);
|
||||
if (!chip->saved_regs) {
|
||||
snd_cs46xx_free(chip);
|
||||
return -ENOMEM;
|
||||
|
@@ -240,10 +240,13 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip)
|
||||
return NULL;
|
||||
|
||||
/* better to use vmalloc for this big table */
|
||||
ins->symbol_table.symbols = vmalloc(sizeof(struct dsp_symbol_entry) *
|
||||
DSP_MAX_SYMBOLS);
|
||||
ins->symbol_table.symbols =
|
||||
vmalloc(array_size(DSP_MAX_SYMBOLS,
|
||||
sizeof(struct dsp_symbol_entry)));
|
||||
ins->code.data = kmalloc(DSP_CODE_BYTE_SIZE, GFP_KERNEL);
|
||||
ins->modules = kmalloc(sizeof(struct dsp_module_desc) * DSP_MAX_MODULES, GFP_KERNEL);
|
||||
ins->modules = kmalloc_array(DSP_MAX_MODULES,
|
||||
sizeof(struct dsp_module_desc),
|
||||
GFP_KERNEL);
|
||||
if (!ins->symbol_table.symbols || !ins->code.data || !ins->modules) {
|
||||
cs46xx_dsp_spos_destroy(chip);
|
||||
goto error;
|
||||
|
@@ -275,7 +275,7 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm)
|
||||
|
||||
/* Get AMIXER resource */
|
||||
n_amixer = (n_amixer < 2) ? 2 : n_amixer;
|
||||
apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
|
||||
apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL);
|
||||
if (!apcm->amixers) {
|
||||
err = -ENOMEM;
|
||||
goto error1;
|
||||
@@ -543,18 +543,18 @@ atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm)
|
||||
}
|
||||
|
||||
if (n_srcc) {
|
||||
apcm->srccs = kzalloc(sizeof(void *)*n_srcc, GFP_KERNEL);
|
||||
apcm->srccs = kcalloc(n_srcc, sizeof(void *), GFP_KERNEL);
|
||||
if (!apcm->srccs)
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (n_amixer) {
|
||||
apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
|
||||
apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL);
|
||||
if (!apcm->amixers) {
|
||||
err = -ENOMEM;
|
||||
goto error1;
|
||||
}
|
||||
}
|
||||
apcm->srcimps = kzalloc(sizeof(void *)*n_srcimp, GFP_KERNEL);
|
||||
apcm->srcimps = kcalloc(n_srcimp, sizeof(void *), GFP_KERNEL);
|
||||
if (!apcm->srcimps) {
|
||||
err = -ENOMEM;
|
||||
goto error1;
|
||||
@@ -819,7 +819,7 @@ static int spdif_passthru_playback_get_resources(struct ct_atc *atc,
|
||||
|
||||
/* Get AMIXER resource */
|
||||
n_amixer = (n_amixer < 2) ? 2 : n_amixer;
|
||||
apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
|
||||
apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL);
|
||||
if (!apcm->amixers) {
|
||||
err = -ENOMEM;
|
||||
goto error1;
|
||||
@@ -1378,19 +1378,19 @@ static int atc_get_resources(struct ct_atc *atc)
|
||||
num_daios = ((atc->model == CTSB1270) ? 8 : 7);
|
||||
num_srcs = ((atc->model == CTSB1270) ? 6 : 4);
|
||||
|
||||
atc->daios = kzalloc(sizeof(void *)*num_daios, GFP_KERNEL);
|
||||
atc->daios = kcalloc(num_daios, sizeof(void *), GFP_KERNEL);
|
||||
if (!atc->daios)
|
||||
return -ENOMEM;
|
||||
|
||||
atc->srcs = kzalloc(sizeof(void *)*num_srcs, GFP_KERNEL);
|
||||
atc->srcs = kcalloc(num_srcs, sizeof(void *), GFP_KERNEL);
|
||||
if (!atc->srcs)
|
||||
return -ENOMEM;
|
||||
|
||||
atc->srcimps = kzalloc(sizeof(void *)*num_srcs, GFP_KERNEL);
|
||||
atc->srcimps = kcalloc(num_srcs, sizeof(void *), GFP_KERNEL);
|
||||
if (!atc->srcimps)
|
||||
return -ENOMEM;
|
||||
|
||||
atc->pcm = kzalloc(sizeof(void *)*(2*4), GFP_KERNEL);
|
||||
atc->pcm = kcalloc(2 * 4, sizeof(void *), GFP_KERNEL);
|
||||
if (!atc->pcm)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -398,7 +398,8 @@ static int dao_rsc_init(struct dao *dao,
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
dao->imappers = kzalloc(sizeof(void *)*desc->msr*2, GFP_KERNEL);
|
||||
dao->imappers = kzalloc(array3_size(sizeof(void *), desc->msr, 2),
|
||||
GFP_KERNEL);
|
||||
if (!dao->imappers) {
|
||||
err = -ENOMEM;
|
||||
goto error1;
|
||||
|
@@ -910,13 +910,14 @@ static int ct_mixer_get_mem(struct ct_mixer **rmixer)
|
||||
if (!mixer)
|
||||
return -ENOMEM;
|
||||
|
||||
mixer->amixers = kzalloc(sizeof(void *)*(NUM_CT_AMIXERS*CHN_NUM),
|
||||
mixer->amixers = kcalloc(NUM_CT_AMIXERS * CHN_NUM, sizeof(void *),
|
||||
GFP_KERNEL);
|
||||
if (!mixer->amixers) {
|
||||
err = -ENOMEM;
|
||||
goto error1;
|
||||
}
|
||||
mixer->sums = kzalloc(sizeof(void *)*(NUM_CT_SUMS*CHN_NUM), GFP_KERNEL);
|
||||
mixer->sums = kcalloc(NUM_CT_SUMS * CHN_NUM, sizeof(void *),
|
||||
GFP_KERNEL);
|
||||
if (!mixer->sums) {
|
||||
err = -ENOMEM;
|
||||
goto error2;
|
||||
|
@@ -679,7 +679,7 @@ static int srcimp_rsc_init(struct srcimp *srcimp,
|
||||
return err;
|
||||
|
||||
/* Reserve memory for imapper nodes */
|
||||
srcimp->imappers = kzalloc(sizeof(struct imapper)*desc->msr,
|
||||
srcimp->imappers = kcalloc(desc->msr, sizeof(struct imapper),
|
||||
GFP_KERNEL);
|
||||
if (!srcimp->imappers) {
|
||||
err = -ENOMEM;
|
||||
|
@@ -1941,9 +1941,10 @@ int snd_emu10k1_create(struct snd_card *card,
|
||||
(unsigned long)emu->ptb_pages.addr,
|
||||
(unsigned long)(emu->ptb_pages.addr + emu->ptb_pages.bytes));
|
||||
|
||||
emu->page_ptr_table = vmalloc(emu->max_cache_pages * sizeof(void *));
|
||||
emu->page_addr_table = vmalloc(emu->max_cache_pages *
|
||||
sizeof(unsigned long));
|
||||
emu->page_ptr_table = vmalloc(array_size(sizeof(void *),
|
||||
emu->max_cache_pages));
|
||||
emu->page_addr_table = vmalloc(array_size(sizeof(unsigned long),
|
||||
emu->max_cache_pages));
|
||||
if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) {
|
||||
err = -ENOMEM;
|
||||
goto error;
|
||||
@@ -2099,7 +2100,7 @@ static int alloc_pm_buffer(struct snd_emu10k1 *emu)
|
||||
size = ARRAY_SIZE(saved_regs);
|
||||
if (emu->audigy)
|
||||
size += ARRAY_SIZE(saved_regs_audigy);
|
||||
emu->saved_ptr = vmalloc(4 * NUM_G * size);
|
||||
emu->saved_ptr = vmalloc(array3_size(4, NUM_G, size));
|
||||
if (!emu->saved_ptr)
|
||||
return -ENOMEM;
|
||||
if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0)
|
||||
|
@@ -2683,16 +2683,16 @@ int snd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu)
|
||||
int len;
|
||||
|
||||
len = emu->audigy ? 0x200 : 0x100;
|
||||
emu->saved_gpr = kmalloc(len * 4, GFP_KERNEL);
|
||||
emu->saved_gpr = kmalloc_array(len, 4, GFP_KERNEL);
|
||||
if (! emu->saved_gpr)
|
||||
return -ENOMEM;
|
||||
len = emu->audigy ? 0x100 : 0xa0;
|
||||
emu->tram_val_saved = kmalloc(len * 4, GFP_KERNEL);
|
||||
emu->tram_addr_saved = kmalloc(len * 4, GFP_KERNEL);
|
||||
emu->tram_val_saved = kmalloc_array(len, 4, GFP_KERNEL);
|
||||
emu->tram_addr_saved = kmalloc_array(len, 4, GFP_KERNEL);
|
||||
if (! emu->tram_val_saved || ! emu->tram_addr_saved)
|
||||
return -ENOMEM;
|
||||
len = emu->audigy ? 2 * 1024 : 2 * 512;
|
||||
emu->saved_icode = vmalloc(len * 4);
|
||||
emu->saved_icode = vmalloc(array_size(len, 4));
|
||||
if (! emu->saved_icode)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
|
@@ -874,7 +874,7 @@ int snd_p16v_mixer(struct snd_emu10k1 *emu)
|
||||
|
||||
int snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu)
|
||||
{
|
||||
emu->p16v_saved = vmalloc(NUM_CHS * 4 * 0x80);
|
||||
emu->p16v_saved = vmalloc(array_size(NUM_CHS * 4, 0x80));
|
||||
if (! emu->p16v_saved)
|
||||
return -ENOMEM;
|
||||
return 0;
|
||||
|
@@ -158,7 +158,7 @@ static int read_and_add_raw_conns(struct hda_codec *codec, hda_nid_t nid)
|
||||
len = snd_hda_get_raw_connections(codec, nid, list, ARRAY_SIZE(list));
|
||||
if (len == -ENOSPC) {
|
||||
len = snd_hda_get_num_raw_conns(codec, nid);
|
||||
result = kmalloc(sizeof(hda_nid_t) * len, GFP_KERNEL);
|
||||
result = kmalloc_array(len, sizeof(hda_nid_t), GFP_KERNEL);
|
||||
if (!result)
|
||||
return -ENOMEM;
|
||||
len = snd_hda_get_raw_connections(codec, nid, result, len);
|
||||
@@ -438,7 +438,7 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
|
||||
int i;
|
||||
hda_nid_t nid;
|
||||
|
||||
codec->wcaps = kmalloc(codec->core.num_nodes * 4, GFP_KERNEL);
|
||||
codec->wcaps = kmalloc_array(codec->core.num_nodes, 4, GFP_KERNEL);
|
||||
if (!codec->wcaps)
|
||||
return -ENOMEM;
|
||||
nid = codec->core.start_nid;
|
||||
|
@@ -825,8 +825,9 @@ static void print_codec_info(struct snd_info_entry *entry,
|
||||
if (wid_caps & AC_WCAP_CONN_LIST) {
|
||||
conn_len = snd_hda_get_num_raw_conns(codec, nid);
|
||||
if (conn_len > 0) {
|
||||
conn = kmalloc(sizeof(hda_nid_t) * conn_len,
|
||||
GFP_KERNEL);
|
||||
conn = kmalloc_array(conn_len,
|
||||
sizeof(hda_nid_t),
|
||||
GFP_KERNEL);
|
||||
if (!conn)
|
||||
return;
|
||||
if (snd_hda_get_raw_connections(codec, nid, conn,
|
||||
|
@@ -7482,7 +7482,9 @@ static int ca0132_prepare_verbs(struct hda_codec *codec)
|
||||
spec->chip_init_verbs = ca0132_init_verbs0;
|
||||
if (spec->quirk == QUIRK_SBZ)
|
||||
spec->sbz_init_verbs = sbz_init_verbs;
|
||||
spec->spec_init_verbs = kzalloc(sizeof(struct hda_verb) * NUM_SPEC_VERBS, GFP_KERNEL);
|
||||
spec->spec_init_verbs = kcalloc(NUM_SPEC_VERBS,
|
||||
sizeof(struct hda_verb),
|
||||
GFP_KERNEL);
|
||||
if (!spec->spec_init_verbs)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -2657,7 +2657,10 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
|
||||
chip->irq = pci->irq;
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
chip->suspend_mem = vmalloc(sizeof(u16) * (REV_B_CODE_MEMORY_LENGTH + REV_B_DATA_MEMORY_LENGTH));
|
||||
chip->suspend_mem =
|
||||
vmalloc(array_size(sizeof(u16),
|
||||
REV_B_CODE_MEMORY_LENGTH +
|
||||
REV_B_DATA_MEMORY_LENGTH));
|
||||
if (chip->suspend_mem == NULL)
|
||||
dev_warn(card->dev, "can't allocate apm buffer\n");
|
||||
#endif
|
||||
|
@@ -3362,7 +3362,9 @@ static int snd_trident_tlb_alloc(struct snd_trident *trident)
|
||||
trident->tlb.entries = (unsigned int*)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4);
|
||||
trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer.addr, SNDRV_TRIDENT_MAX_PAGES * 4);
|
||||
/* allocate shadow TLB page table (virtual addresses) */
|
||||
trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long));
|
||||
trident->tlb.shadow_entries =
|
||||
vmalloc(array_size(SNDRV_TRIDENT_MAX_PAGES,
|
||||
sizeof(unsigned long)));
|
||||
if (!trident->tlb.shadow_entries)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -439,7 +439,9 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (! dev->idx_table) {
|
||||
dev->idx_table = kmalloc(sizeof(*dev->idx_table) * VIA_TABLE_SIZE, GFP_KERNEL);
|
||||
dev->idx_table = kmalloc_array(VIA_TABLE_SIZE,
|
||||
sizeof(*dev->idx_table),
|
||||
GFP_KERNEL);
|
||||
if (! dev->idx_table)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@@ -292,7 +292,9 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre
|
||||
return -ENOMEM;
|
||||
}
|
||||
if (! dev->idx_table) {
|
||||
dev->idx_table = kmalloc(sizeof(*dev->idx_table) * VIA_TABLE_SIZE, GFP_KERNEL);
|
||||
dev->idx_table = kmalloc_array(VIA_TABLE_SIZE,
|
||||
sizeof(*dev->idx_table),
|
||||
GFP_KERNEL);
|
||||
if (! dev->idx_table)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@@ -2435,8 +2435,8 @@ int snd_ymfpci_create(struct snd_card *card,
|
||||
goto free_chip;
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
chip->saved_regs = kmalloc(YDSXGR_NUM_SAVED_REGS * sizeof(u32),
|
||||
GFP_KERNEL);
|
||||
chip->saved_regs = kmalloc_array(YDSXGR_NUM_SAVED_REGS, sizeof(u32),
|
||||
GFP_KERNEL);
|
||||
if (chip->saved_regs == NULL) {
|
||||
err = -ENOMEM;
|
||||
goto free_chip;
|
||||
|
@@ -339,8 +339,8 @@ static int au1xpsc_pcm_drvprobe(struct platform_device *pdev)
|
||||
{
|
||||
struct au1xpsc_audio_dmadata *dmadata;
|
||||
|
||||
dmadata = devm_kzalloc(&pdev->dev,
|
||||
2 * sizeof(struct au1xpsc_audio_dmadata),
|
||||
dmadata = devm_kcalloc(&pdev->dev,
|
||||
2, sizeof(struct au1xpsc_audio_dmadata),
|
||||
GFP_KERNEL);
|
||||
if (!dmadata)
|
||||
return -ENOMEM;
|
||||
|
@@ -771,7 +771,7 @@ static int hdmi_codec_probe(struct platform_device *pdev)
|
||||
hcp->hcd = *hcd;
|
||||
mutex_init(&hcp->current_stream_lock);
|
||||
|
||||
hcp->daidrv = devm_kzalloc(dev, dai_count * sizeof(*hcp->daidrv),
|
||||
hcp->daidrv = devm_kcalloc(dev, dai_count, sizeof(*hcp->daidrv),
|
||||
GFP_KERNEL);
|
||||
if (!hcp->daidrv)
|
||||
return -ENOMEM;
|
||||
|
@@ -3449,8 +3449,9 @@ static int rt5645_probe(struct snd_soc_component *component)
|
||||
if (rt5645->pdata.long_name)
|
||||
component->card->long_name = rt5645->pdata.long_name;
|
||||
|
||||
rt5645->eq_param = devm_kzalloc(component->dev,
|
||||
RT5645_HWEQ_NUM * sizeof(struct rt5645_eq_param_s), GFP_KERNEL);
|
||||
rt5645->eq_param = devm_kcalloc(component->dev,
|
||||
RT5645_HWEQ_NUM, sizeof(struct rt5645_eq_param_s),
|
||||
GFP_KERNEL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -2023,8 +2023,9 @@ static void wm8904_handle_pdata(struct snd_soc_component *component)
|
||||
wm8904_get_drc_enum, wm8904_put_drc_enum);
|
||||
|
||||
/* We need an array of texts for the enum API */
|
||||
wm8904->drc_texts = kmalloc(sizeof(char *)
|
||||
* pdata->num_drc_cfgs, GFP_KERNEL);
|
||||
wm8904->drc_texts = kmalloc_array(pdata->num_drc_cfgs,
|
||||
sizeof(char *),
|
||||
GFP_KERNEL);
|
||||
if (!wm8904->drc_texts)
|
||||
return;
|
||||
|
||||
|
@@ -932,8 +932,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component)
|
||||
};
|
||||
|
||||
/* We need an array of texts for the enum API */
|
||||
wm8994->mbc_texts = kmalloc(sizeof(char *)
|
||||
* pdata->num_mbc_cfgs, GFP_KERNEL);
|
||||
wm8994->mbc_texts = kmalloc_array(pdata->num_mbc_cfgs,
|
||||
sizeof(char *),
|
||||
GFP_KERNEL);
|
||||
if (!wm8994->mbc_texts)
|
||||
return;
|
||||
|
||||
@@ -957,8 +958,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component)
|
||||
};
|
||||
|
||||
/* We need an array of texts for the enum API */
|
||||
wm8994->vss_texts = kmalloc(sizeof(char *)
|
||||
* pdata->num_vss_cfgs, GFP_KERNEL);
|
||||
wm8994->vss_texts = kmalloc_array(pdata->num_vss_cfgs,
|
||||
sizeof(char *),
|
||||
GFP_KERNEL);
|
||||
if (!wm8994->vss_texts)
|
||||
return;
|
||||
|
||||
@@ -983,8 +985,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component)
|
||||
};
|
||||
|
||||
/* We need an array of texts for the enum API */
|
||||
wm8994->vss_hpf_texts = kmalloc(sizeof(char *)
|
||||
* pdata->num_vss_hpf_cfgs, GFP_KERNEL);
|
||||
wm8994->vss_hpf_texts = kmalloc_array(pdata->num_vss_hpf_cfgs,
|
||||
sizeof(char *),
|
||||
GFP_KERNEL);
|
||||
if (!wm8994->vss_hpf_texts)
|
||||
return;
|
||||
|
||||
@@ -1010,8 +1013,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component)
|
||||
};
|
||||
|
||||
/* We need an array of texts for the enum API */
|
||||
wm8994->enh_eq_texts = kmalloc(sizeof(char *)
|
||||
* pdata->num_enh_eq_cfgs, GFP_KERNEL);
|
||||
wm8994->enh_eq_texts = kmalloc_array(pdata->num_enh_eq_cfgs,
|
||||
sizeof(char *),
|
||||
GFP_KERNEL);
|
||||
if (!wm8994->enh_eq_texts)
|
||||
return;
|
||||
|
||||
|
@@ -3298,8 +3298,8 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
|
||||
};
|
||||
|
||||
/* We need an array of texts for the enum API */
|
||||
wm8994->drc_texts = devm_kzalloc(wm8994->hubs.component->dev,
|
||||
sizeof(char *) * pdata->num_drc_cfgs, GFP_KERNEL);
|
||||
wm8994->drc_texts = devm_kcalloc(wm8994->hubs.component->dev,
|
||||
pdata->num_drc_cfgs, sizeof(char *), GFP_KERNEL);
|
||||
if (!wm8994->drc_texts)
|
||||
return;
|
||||
|
||||
|
@@ -1899,7 +1899,7 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs,
|
||||
adsp_warn(dsp, "Algorithm list end %x 0x%x != 0xbedead\n",
|
||||
pos + len, be32_to_cpu(val));
|
||||
|
||||
alg = kzalloc(len * 2, GFP_KERNEL | GFP_DMA);
|
||||
alg = kcalloc(len, 2, GFP_KERNEL | GFP_DMA);
|
||||
if (!alg)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
|
@@ -1868,8 +1868,8 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
|
||||
|
||||
mcasp->num_serializer = pdata->num_serializer;
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
mcasp->context.xrsr_regs = devm_kzalloc(&pdev->dev,
|
||||
sizeof(u32) * mcasp->num_serializer,
|
||||
mcasp->context.xrsr_regs = devm_kcalloc(&pdev->dev,
|
||||
mcasp->num_serializer, sizeof(u32),
|
||||
GFP_KERNEL);
|
||||
if (!mcasp->context.xrsr_regs) {
|
||||
ret = -ENOMEM;
|
||||
@@ -2004,13 +2004,15 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
|
||||
* bytes.
|
||||
*/
|
||||
mcasp->chconstr[SNDRV_PCM_STREAM_PLAYBACK].list =
|
||||
devm_kzalloc(mcasp->dev, sizeof(unsigned int) *
|
||||
(32 + mcasp->num_serializer - 1),
|
||||
devm_kcalloc(mcasp->dev,
|
||||
32 + mcasp->num_serializer - 1,
|
||||
sizeof(unsigned int),
|
||||
GFP_KERNEL);
|
||||
|
||||
mcasp->chconstr[SNDRV_PCM_STREAM_CAPTURE].list =
|
||||
devm_kzalloc(mcasp->dev, sizeof(unsigned int) *
|
||||
(32 + mcasp->num_serializer - 1),
|
||||
devm_kcalloc(mcasp->dev,
|
||||
32 + mcasp->num_serializer - 1,
|
||||
sizeof(unsigned int),
|
||||
GFP_KERNEL);
|
||||
|
||||
if (!mcasp->chconstr[SNDRV_PCM_STREAM_PLAYBACK].list ||
|
||||
|
@@ -296,8 +296,8 @@ static int asoc_graph_card_probe(struct platform_device *pdev)
|
||||
if (num == 0)
|
||||
return -EINVAL;
|
||||
|
||||
dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
|
||||
dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL);
|
||||
dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL);
|
||||
dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL);
|
||||
if (!dai_props || !dai_link)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -348,8 +348,8 @@ static int asoc_graph_card_probe(struct platform_device *pdev)
|
||||
if (num == 0)
|
||||
return -EINVAL;
|
||||
|
||||
dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
|
||||
dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL);
|
||||
dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL);
|
||||
dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL);
|
||||
if (!dai_props || !dai_link)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -340,8 +340,8 @@ static int asoc_simple_card_parse_aux_devs(struct device_node *node,
|
||||
if (n <= 0)
|
||||
return -EINVAL;
|
||||
|
||||
card->aux_dev = devm_kzalloc(dev,
|
||||
n * sizeof(*card->aux_dev), GFP_KERNEL);
|
||||
card->aux_dev = devm_kcalloc(dev,
|
||||
n, sizeof(*card->aux_dev), GFP_KERNEL);
|
||||
if (!card->aux_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -435,8 +435,8 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
|
||||
if (!priv)
|
||||
return -ENOMEM;
|
||||
|
||||
dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
|
||||
dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL);
|
||||
dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL);
|
||||
dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL);
|
||||
if (!dai_props || !dai_link)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -246,8 +246,8 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
|
||||
|
||||
num = of_get_child_count(np);
|
||||
|
||||
dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
|
||||
dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL);
|
||||
dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL);
|
||||
dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL);
|
||||
if (!dai_props || !dai_link)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -509,8 +509,8 @@ static int img_i2s_in_probe(struct platform_device *pdev)
|
||||
|
||||
pm_runtime_put(&pdev->dev);
|
||||
|
||||
i2s->suspend_ch_ctl = devm_kzalloc(dev,
|
||||
sizeof(*i2s->suspend_ch_ctl) * i2s->max_i2s_chan, GFP_KERNEL);
|
||||
i2s->suspend_ch_ctl = devm_kcalloc(dev,
|
||||
i2s->max_i2s_chan, sizeof(*i2s->suspend_ch_ctl), GFP_KERNEL);
|
||||
if (!i2s->suspend_ch_ctl) {
|
||||
ret = -ENOMEM;
|
||||
goto err_suspend;
|
||||
|
@@ -479,8 +479,8 @@ static int img_i2s_out_probe(struct platform_device *pdev)
|
||||
return PTR_ERR(i2s->clk_ref);
|
||||
}
|
||||
|
||||
i2s->suspend_ch_ctl = devm_kzalloc(dev,
|
||||
sizeof(*i2s->suspend_ch_ctl) * i2s->max_i2s_chan, GFP_KERNEL);
|
||||
i2s->suspend_ch_ctl = devm_kcalloc(dev,
|
||||
i2s->max_i2s_chan, sizeof(*i2s->suspend_ch_ctl), GFP_KERNEL);
|
||||
if (!i2s->suspend_ch_ctl)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -121,8 +121,8 @@ static int msg_empty_list_init(struct sst_generic_ipc *ipc)
|
||||
{
|
||||
int i;
|
||||
|
||||
ipc->msg = kzalloc(sizeof(struct ipc_message) *
|
||||
IPC_EMPTY_LIST_SIZE, GFP_KERNEL);
|
||||
ipc->msg = kcalloc(IPC_EMPTY_LIST_SIZE, sizeof(struct ipc_message),
|
||||
GFP_KERNEL);
|
||||
if (ipc->msg == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -2428,8 +2428,10 @@ static int skl_tplg_get_token(struct device *dev,
|
||||
|
||||
case SKL_TKN_U8_DYN_IN_PIN:
|
||||
if (!mconfig->m_in_pin)
|
||||
mconfig->m_in_pin = devm_kzalloc(dev, MAX_IN_QUEUE *
|
||||
sizeof(*mconfig->m_in_pin), GFP_KERNEL);
|
||||
mconfig->m_in_pin =
|
||||
devm_kcalloc(dev, MAX_IN_QUEUE,
|
||||
sizeof(*mconfig->m_in_pin),
|
||||
GFP_KERNEL);
|
||||
if (!mconfig->m_in_pin)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -2439,8 +2441,10 @@ static int skl_tplg_get_token(struct device *dev,
|
||||
|
||||
case SKL_TKN_U8_DYN_OUT_PIN:
|
||||
if (!mconfig->m_out_pin)
|
||||
mconfig->m_out_pin = devm_kzalloc(dev, MAX_IN_QUEUE *
|
||||
sizeof(*mconfig->m_in_pin), GFP_KERNEL);
|
||||
mconfig->m_out_pin =
|
||||
devm_kcalloc(dev, MAX_IN_QUEUE,
|
||||
sizeof(*mconfig->m_in_pin),
|
||||
GFP_KERNEL);
|
||||
if (!mconfig->m_out_pin)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -2852,14 +2856,14 @@ static int skl_tplg_get_pvt_data_v4(struct snd_soc_tplg_dapm_widget *tplg_w,
|
||||
mconfig->time_slot = dfw->time_slot;
|
||||
mconfig->formats_config.caps_size = dfw->caps.caps_size;
|
||||
|
||||
mconfig->m_in_pin = devm_kzalloc(dev,
|
||||
MAX_IN_QUEUE * sizeof(*mconfig->m_in_pin),
|
||||
mconfig->m_in_pin = devm_kcalloc(dev,
|
||||
MAX_IN_QUEUE, sizeof(*mconfig->m_in_pin),
|
||||
GFP_KERNEL);
|
||||
if (!mconfig->m_in_pin)
|
||||
return -ENOMEM;
|
||||
|
||||
mconfig->m_out_pin = devm_kzalloc(dev,
|
||||
MAX_OUT_QUEUE * sizeof(*mconfig->m_out_pin),
|
||||
mconfig->m_out_pin = devm_kcalloc(dev,
|
||||
MAX_OUT_QUEUE, sizeof(*mconfig->m_out_pin),
|
||||
GFP_KERNEL);
|
||||
if (!mconfig->m_out_pin)
|
||||
return -ENOMEM;
|
||||
|
@@ -1347,7 +1347,8 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
|
||||
afe->dev = &pdev->dev;
|
||||
dev = afe->dev;
|
||||
|
||||
afe_priv->i2s_path = devm_kzalloc(dev, afe_priv->soc->i2s_num *
|
||||
afe_priv->i2s_path = devm_kcalloc(dev,
|
||||
afe_priv->soc->i2s_num,
|
||||
sizeof(struct mt2701_i2s_path),
|
||||
GFP_KERNEL);
|
||||
if (!afe_priv->i2s_path)
|
||||
|
@@ -425,8 +425,8 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev)
|
||||
if (priv->sspa == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
priv->dma_params = devm_kzalloc(&pdev->dev,
|
||||
2 * sizeof(struct snd_dmaengine_dai_dma_data),
|
||||
priv->dma_params = devm_kcalloc(&pdev->dev,
|
||||
2, sizeof(struct snd_dmaengine_dai_dma_data),
|
||||
GFP_KERNEL);
|
||||
if (priv->dma_params == NULL)
|
||||
return -ENOMEM;
|
||||
|
@@ -462,7 +462,7 @@ static int rockchip_sound_of_parse_dais(struct device *dev,
|
||||
num_routes = 0;
|
||||
for (i = 0; i < ARRAY_SIZE(rockchip_routes); i++)
|
||||
num_routes += rockchip_routes[i].num_routes;
|
||||
routes = devm_kzalloc(dev, num_routes * sizeof(*routes),
|
||||
routes = devm_kcalloc(dev, num_routes, sizeof(*routes),
|
||||
GFP_KERNEL);
|
||||
if (!routes)
|
||||
return -ENOMEM;
|
||||
|
@@ -155,7 +155,7 @@ int rsnd_cmd_probe(struct rsnd_priv *priv)
|
||||
if (!nr)
|
||||
return 0;
|
||||
|
||||
cmd = devm_kzalloc(dev, sizeof(*cmd) * nr, GFP_KERNEL);
|
||||
cmd = devm_kcalloc(dev, nr, sizeof(*cmd), GFP_KERNEL);
|
||||
if (!cmd)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -1110,8 +1110,8 @@ static int rsnd_dai_probe(struct rsnd_priv *priv)
|
||||
if (!nr)
|
||||
return -EINVAL;
|
||||
|
||||
rdrv = devm_kzalloc(dev, sizeof(*rdrv) * nr, GFP_KERNEL);
|
||||
rdai = devm_kzalloc(dev, sizeof(*rdai) * nr, GFP_KERNEL);
|
||||
rdrv = devm_kcalloc(dev, nr, sizeof(*rdrv), GFP_KERNEL);
|
||||
rdai = devm_kcalloc(dev, nr, sizeof(*rdai), GFP_KERNEL);
|
||||
if (!rdrv || !rdai)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -378,7 +378,7 @@ int rsnd_ctu_probe(struct rsnd_priv *priv)
|
||||
goto rsnd_ctu_probe_done;
|
||||
}
|
||||
|
||||
ctu = devm_kzalloc(dev, sizeof(*ctu) * nr, GFP_KERNEL);
|
||||
ctu = devm_kcalloc(dev, nr, sizeof(*ctu), GFP_KERNEL);
|
||||
if (!ctu) {
|
||||
ret = -ENOMEM;
|
||||
goto rsnd_ctu_probe_done;
|
||||
|
@@ -344,7 +344,7 @@ int rsnd_dvc_probe(struct rsnd_priv *priv)
|
||||
goto rsnd_dvc_probe_done;
|
||||
}
|
||||
|
||||
dvc = devm_kzalloc(dev, sizeof(*dvc) * nr, GFP_KERNEL);
|
||||
dvc = devm_kcalloc(dev, nr, sizeof(*dvc), GFP_KERNEL);
|
||||
if (!dvc) {
|
||||
ret = -ENOMEM;
|
||||
goto rsnd_dvc_probe_done;
|
||||
|
@@ -294,7 +294,7 @@ int rsnd_mix_probe(struct rsnd_priv *priv)
|
||||
goto rsnd_mix_probe_done;
|
||||
}
|
||||
|
||||
mix = devm_kzalloc(dev, sizeof(*mix) * nr, GFP_KERNEL);
|
||||
mix = devm_kcalloc(dev, nr, sizeof(*mix), GFP_KERNEL);
|
||||
if (!mix) {
|
||||
ret = -ENOMEM;
|
||||
goto rsnd_mix_probe_done;
|
||||
|
@@ -575,7 +575,7 @@ int rsnd_src_probe(struct rsnd_priv *priv)
|
||||
goto rsnd_src_probe_done;
|
||||
}
|
||||
|
||||
src = devm_kzalloc(dev, sizeof(*src) * nr, GFP_KERNEL);
|
||||
src = devm_kcalloc(dev, nr, sizeof(*src), GFP_KERNEL);
|
||||
if (!src) {
|
||||
ret = -ENOMEM;
|
||||
goto rsnd_src_probe_done;
|
||||
|
@@ -1116,7 +1116,7 @@ int rsnd_ssi_probe(struct rsnd_priv *priv)
|
||||
goto rsnd_ssi_probe_done;
|
||||
}
|
||||
|
||||
ssi = devm_kzalloc(dev, sizeof(*ssi) * nr, GFP_KERNEL);
|
||||
ssi = devm_kcalloc(dev, nr, sizeof(*ssi), GFP_KERNEL);
|
||||
if (!ssi) {
|
||||
ret = -ENOMEM;
|
||||
goto rsnd_ssi_probe_done;
|
||||
|
@@ -258,7 +258,7 @@ int rsnd_ssiu_probe(struct rsnd_priv *priv)
|
||||
|
||||
/* same number to SSI */
|
||||
nr = priv->ssi_nr;
|
||||
ssiu = devm_kzalloc(dev, sizeof(*ssiu) * nr, GFP_KERNEL);
|
||||
ssiu = devm_kcalloc(dev, nr, sizeof(*ssiu), GFP_KERNEL);
|
||||
if (!ssiu)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -373,8 +373,8 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
|
||||
if (!rtd->dai_link->ops)
|
||||
rtd->dai_link->ops = &null_snd_soc_ops;
|
||||
|
||||
rtd->codec_dais = kzalloc(sizeof(struct snd_soc_dai *) *
|
||||
dai_link->num_codecs,
|
||||
rtd->codec_dais = kcalloc(dai_link->num_codecs,
|
||||
sizeof(struct snd_soc_dai *),
|
||||
GFP_KERNEL);
|
||||
if (!rtd->codec_dais) {
|
||||
kfree(rtd);
|
||||
@@ -3354,7 +3354,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes),
|
||||
routes = devm_kcalloc(card->dev, num_routes, sizeof(*routes),
|
||||
GFP_KERNEL);
|
||||
if (!routes) {
|
||||
dev_err(card->dev,
|
||||
@@ -3678,8 +3678,8 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev,
|
||||
dev_err(dev, "Bad phandle in 'sound-dai'\n");
|
||||
return num_codecs;
|
||||
}
|
||||
component = devm_kzalloc(dev,
|
||||
sizeof *component * num_codecs,
|
||||
component = devm_kcalloc(dev,
|
||||
num_codecs, sizeof(*component),
|
||||
GFP_KERNEL);
|
||||
if (!component)
|
||||
return -ENOMEM;
|
||||
|
@@ -3055,7 +3055,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card)
|
||||
continue;
|
||||
|
||||
if (w->num_kcontrols) {
|
||||
w->kcontrols = kzalloc(w->num_kcontrols *
|
||||
w->kcontrols = kcalloc(w->num_kcontrols,
|
||||
sizeof(struct snd_kcontrol *),
|
||||
GFP_KERNEL);
|
||||
if (!w->kcontrols) {
|
||||
|
@@ -885,7 +885,7 @@ static int soc_tplg_denum_create_texts(struct soc_enum *se,
|
||||
int i, ret;
|
||||
|
||||
se->dobj.control.dtexts =
|
||||
kzalloc(sizeof(char *) * ec->items, GFP_KERNEL);
|
||||
kcalloc(ec->items, sizeof(char *), GFP_KERNEL);
|
||||
if (se->dobj.control.dtexts == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -624,15 +624,17 @@ int uniphier_aio_probe(struct platform_device *pdev)
|
||||
return PTR_ERR(chip->rst);
|
||||
|
||||
chip->num_aios = chip->chip_spec->num_dais;
|
||||
chip->aios = devm_kzalloc(dev,
|
||||
sizeof(struct uniphier_aio) * chip->num_aios,
|
||||
chip->aios = devm_kcalloc(dev,
|
||||
chip->num_aios, sizeof(struct uniphier_aio),
|
||||
GFP_KERNEL);
|
||||
if (!chip->aios)
|
||||
return -ENOMEM;
|
||||
|
||||
chip->num_plls = chip->chip_spec->num_plls;
|
||||
chip->plls = devm_kzalloc(dev, sizeof(struct uniphier_aio_pll) *
|
||||
chip->num_plls, GFP_KERNEL);
|
||||
chip->plls = devm_kcalloc(dev,
|
||||
chip->num_plls,
|
||||
sizeof(struct uniphier_aio_pll),
|
||||
GFP_KERNEL);
|
||||
if (!chip->plls)
|
||||
return -ENOMEM;
|
||||
memcpy(chip->plls, chip->chip_spec->plls,
|
||||
|
@@ -591,12 +591,14 @@ static int usb6fire_pcm_buffers_init(struct pcm_runtime *rt)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < PCM_N_URBS; i++) {
|
||||
rt->out_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB
|
||||
* PCM_MAX_PACKET_SIZE, GFP_KERNEL);
|
||||
rt->out_urbs[i].buffer = kcalloc(PCM_MAX_PACKET_SIZE,
|
||||
PCM_N_PACKETS_PER_URB,
|
||||
GFP_KERNEL);
|
||||
if (!rt->out_urbs[i].buffer)
|
||||
return -ENOMEM;
|
||||
rt->in_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB
|
||||
* PCM_MAX_PACKET_SIZE, GFP_KERNEL);
|
||||
rt->in_urbs[i].buffer = kcalloc(PCM_MAX_PACKET_SIZE,
|
||||
PCM_N_PACKETS_PER_URB,
|
||||
GFP_KERNEL);
|
||||
if (!rt->in_urbs[i].buffer)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@@ -728,7 +728,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
|
||||
usb_sndisocpipe(usb_dev, ENDPOINT_PLAYBACK) :
|
||||
usb_rcvisocpipe(usb_dev, ENDPOINT_CAPTURE);
|
||||
|
||||
urbs = kmalloc(N_URBS * sizeof(*urbs), GFP_KERNEL);
|
||||
urbs = kmalloc_array(N_URBS, sizeof(*urbs), GFP_KERNEL);
|
||||
if (!urbs) {
|
||||
*ret = -ENOMEM;
|
||||
return NULL;
|
||||
@@ -742,7 +742,8 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
|
||||
}
|
||||
|
||||
urbs[i]->transfer_buffer =
|
||||
kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL);
|
||||
kmalloc_array(BYTES_PER_FRAME, FRAMES_PER_URB,
|
||||
GFP_KERNEL);
|
||||
if (!urbs[i]->transfer_buffer) {
|
||||
*ret = -ENOMEM;
|
||||
return urbs;
|
||||
@@ -857,7 +858,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev)
|
||||
&snd_usb_caiaq_ops);
|
||||
|
||||
cdev->data_cb_info =
|
||||
kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS,
|
||||
kmalloc_array(N_URBS, sizeof(struct snd_usb_caiaq_cb_info),
|
||||
GFP_KERNEL);
|
||||
|
||||
if (!cdev->data_cb_info)
|
||||
|
@@ -188,7 +188,8 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
|
||||
*/
|
||||
int r, idx;
|
||||
|
||||
fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL);
|
||||
fp->rate_table = kmalloc_array(nr_rates, sizeof(int),
|
||||
GFP_KERNEL);
|
||||
if (fp->rate_table == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -362,7 +363,7 @@ static int parse_audio_format_rates_v2v3(struct snd_usb_audio *chip,
|
||||
goto err_free;
|
||||
}
|
||||
|
||||
fp->rate_table = kmalloc(sizeof(int) * fp->nr_rates, GFP_KERNEL);
|
||||
fp->rate_table = kmalloc_array(fp->nr_rates, sizeof(int), GFP_KERNEL);
|
||||
if (!fp->rate_table) {
|
||||
ret = -ENOMEM;
|
||||
goto err_free;
|
||||
|
@@ -264,8 +264,8 @@ int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm)
|
||||
struct usb_line6 *line6 = line6pcm->line6;
|
||||
int i;
|
||||
|
||||
line6pcm->in.urbs = kzalloc(
|
||||
sizeof(struct urb *) * line6->iso_buffers, GFP_KERNEL);
|
||||
line6pcm->in.urbs = kcalloc(line6->iso_buffers, sizeof(struct urb *),
|
||||
GFP_KERNEL);
|
||||
if (line6pcm->in.urbs == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -158,8 +158,10 @@ static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm,
|
||||
|
||||
/* Invoked multiple times in a row so allocate once only */
|
||||
if (!test_and_set_bit(type, &pstr->opened) && !pstr->buffer) {
|
||||
pstr->buffer = kmalloc(line6pcm->line6->iso_buffers *
|
||||
LINE6_ISO_PACKETS * pkt_size, GFP_KERNEL);
|
||||
pstr->buffer =
|
||||
kmalloc(array3_size(line6pcm->line6->iso_buffers,
|
||||
LINE6_ISO_PACKETS, pkt_size),
|
||||
GFP_KERNEL);
|
||||
if (!pstr->buffer)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
@@ -409,8 +409,8 @@ int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm)
|
||||
struct usb_line6 *line6 = line6pcm->line6;
|
||||
int i;
|
||||
|
||||
line6pcm->out.urbs = kzalloc(
|
||||
sizeof(struct urb *) * line6->iso_buffers, GFP_KERNEL);
|
||||
line6pcm->out.urbs = kcalloc(line6->iso_buffers, sizeof(struct urb *),
|
||||
GFP_KERNEL);
|
||||
if (line6pcm->out.urbs == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@@ -2515,7 +2515,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid,
|
||||
cval->control = (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) ?
|
||||
UAC2_CX_CLOCK_SELECTOR : UAC2_SU_SELECTOR;
|
||||
|
||||
namelist = kmalloc(sizeof(char *) * desc->bNrInPins, GFP_KERNEL);
|
||||
namelist = kmalloc_array(desc->bNrInPins, sizeof(char *), GFP_KERNEL);
|
||||
if (!namelist) {
|
||||
kfree(cval);
|
||||
return -ENOMEM;
|
||||
|
@@ -1123,7 +1123,7 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime,
|
||||
return 0;
|
||||
|
||||
subs->rate_list.list = rate_list =
|
||||
kmalloc(sizeof(int) * count, GFP_KERNEL);
|
||||
kmalloc_array(count, sizeof(int), GFP_KERNEL);
|
||||
if (!subs->rate_list.list)
|
||||
return -ENOMEM;
|
||||
subs->rate_list.count = count;
|
||||
|
@@ -266,7 +266,9 @@ int usX2Y_AsyncSeq04_init(struct usX2Ydev *usX2Y)
|
||||
int err = 0,
|
||||
i;
|
||||
|
||||
if (NULL == (usX2Y->AS04.buffer = kmalloc(URB_DataLen_AsyncSeq*URBS_AsyncSeq, GFP_KERNEL))) {
|
||||
usX2Y->AS04.buffer = kmalloc_array(URBS_AsyncSeq,
|
||||
URB_DataLen_AsyncSeq, GFP_KERNEL);
|
||||
if (NULL == usX2Y->AS04.buffer) {
|
||||
err = -ENOMEM;
|
||||
} else
|
||||
for (i = 0; i < URBS_AsyncSeq; ++i) {
|
||||
|
@@ -436,7 +436,9 @@ static int usX2Y_urbs_allocate(struct snd_usX2Y_substream *subs)
|
||||
}
|
||||
if (!is_playback && !(*purb)->transfer_buffer) {
|
||||
/* allocate a capture buffer per urb */
|
||||
(*purb)->transfer_buffer = kmalloc(subs->maxpacksize * nr_of_packs(), GFP_KERNEL);
|
||||
(*purb)->transfer_buffer =
|
||||
kmalloc_array(subs->maxpacksize,
|
||||
nr_of_packs(), GFP_KERNEL);
|
||||
if (NULL == (*purb)->transfer_buffer) {
|
||||
usX2Y_urbs_release(subs);
|
||||
return -ENOMEM;
|
||||
@@ -662,7 +664,8 @@ static int usX2Y_rate_set(struct usX2Ydev *usX2Y, int rate)
|
||||
err = -ENOMEM;
|
||||
goto cleanup;
|
||||
}
|
||||
usbdata = kmalloc(sizeof(int) * NOOF_SETRATE_URBS, GFP_KERNEL);
|
||||
usbdata = kmalloc_array(NOOF_SETRATE_URBS, sizeof(int),
|
||||
GFP_KERNEL);
|
||||
if (NULL == usbdata) {
|
||||
err = -ENOMEM;
|
||||
goto cleanup;
|
||||
|
Referens i nytt ärende
Block a user