mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-02-26 05:31:29 +07:00
ALSA: memalloc: Initialize all fields of snd_dma_buffer properly
Some fields in snd_dma_buffer aren't touched in snd_dma_alloc_pages() and might be left uninitialized. Let's clear all fields properly, so that we can use a NULL check (e.g. dmab->private_data) as conditional in a later patch. Link: https://lore.kernel.org/r/20200615160045.2703-3-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
d955dab33a
commit
28e60dbb83
@ -135,16 +135,17 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size,
|
|||||||
dmab->dev.type = type;
|
dmab->dev.type = type;
|
||||||
dmab->dev.dev = device;
|
dmab->dev.dev = device;
|
||||||
dmab->bytes = 0;
|
dmab->bytes = 0;
|
||||||
|
dmab->area = NULL;
|
||||||
|
dmab->addr = 0;
|
||||||
|
dmab->private_data = NULL;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SNDRV_DMA_TYPE_CONTINUOUS:
|
case SNDRV_DMA_TYPE_CONTINUOUS:
|
||||||
gfp = snd_mem_get_gfp_flags(device, GFP_KERNEL);
|
gfp = snd_mem_get_gfp_flags(device, GFP_KERNEL);
|
||||||
dmab->area = alloc_pages_exact(size, gfp);
|
dmab->area = alloc_pages_exact(size, gfp);
|
||||||
dmab->addr = 0;
|
|
||||||
break;
|
break;
|
||||||
case SNDRV_DMA_TYPE_VMALLOC:
|
case SNDRV_DMA_TYPE_VMALLOC:
|
||||||
gfp = snd_mem_get_gfp_flags(device, GFP_KERNEL | __GFP_HIGHMEM);
|
gfp = snd_mem_get_gfp_flags(device, GFP_KERNEL | __GFP_HIGHMEM);
|
||||||
dmab->area = __vmalloc(size, gfp);
|
dmab->area = __vmalloc(size, gfp);
|
||||||
dmab->addr = 0;
|
|
||||||
break;
|
break;
|
||||||
#ifdef CONFIG_HAS_DMA
|
#ifdef CONFIG_HAS_DMA
|
||||||
#ifdef CONFIG_GENERIC_ALLOCATOR
|
#ifdef CONFIG_GENERIC_ALLOCATOR
|
||||||
@ -171,8 +172,6 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size,
|
|||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
pr_err("snd-malloc: invalid device type %d\n", type);
|
pr_err("snd-malloc: invalid device type %d\n", type);
|
||||||
dmab->area = NULL;
|
|
||||||
dmab->addr = 0;
|
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
if (! dmab->area)
|
if (! dmab->area)
|
||||||
|
Loading…
Reference in New Issue
Block a user