On Tue, 24 Jul 2018 17:57:42 +0200, Pierre-Louis Bossart wrote:
we seem to have a new 0-day report with randconfig related to the page/sgbuffer management. Not sure why it wasn't seen before, I've already fixed quite a few exotic configurations for non-Intel targets.
sound/soc/sof/core.c: In function 'snd_sof_create_page_table': sound/soc/sof/core.c:201:10: error: implicit declaration of function 'snd_sgbuf_aligned_pages' [-Werror=implicit-function-declaration] pages = snd_sgbuf_aligned_pages(size); ^ Looking at the code:
+static inline unsigned int sof_get_pages(size_t size) +{
- return (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
+}
this inline doesn't seem to be used but duplicates the code from
static inline unsigned int snd_sgbuf_aligned_pages(size_t size) { return (size + PAGE_SIZE - 1) >> PAGE_SHIFT; }
which is used below
+int snd_sof_create_page_table(struct snd_sof_dev *sdev,
struct snd_dma_buffer *dmab,
unsigned char *page_table, size_t size)
+{
- int i, pages;
- pages = snd_sgbuf_aligned_pages(size);
this code doesn't compile unless CONFIG_SND_DMA_SGBUF is defined (it is set for the intel-specific code but not for the SOF core). We can fix this in different ways 0. require SND_CMD_SGBUF for the core - likely not desirable
- use sof_get_pages()
- change include/sound/memalloc.h to make sure this
snd_sgbuf_aligned_pages() inline is available whether CONFIG_SND_DMA_SGBUF is defined or not - maybe making sure while we are at it that the malloc and free functions are empty static inlines?
The latter sounds like a better choice to me. Just move the function to outside ifdef.
thanks,
Takashi