[alsa-devel] Allocating DMA buffer for non-PCM

Adrian Knoth adi at drcomp.erfurt.thur.de
Thu Feb 14 18:03:53 CET 2013


Would you say that the following is the proper way to allocate a DMA
buffer used to hold level data?

struct hdspm {
	struct pci_dev *pci;	/* and an pci info */
	struct snd_dma_buffer dmaLevelBuffer;
	u32 *level_buffer;	/* suitably aligned address */

	/* allocate level buffer */
	err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV_SG,
			MADIFX_LEVEL_BUFFER_SIZE, &hdspm->dmaLevelBuffer);
	if (err < 0) {
    /* error */ [..]

    hdspm->level_buffer = snd_sgbuf_get_ptr(&(hdspm->dmaLevelBuffer), 0);

	memset(hdspm->level_buffer, 0, MADIFX_LEVEL_BUFFER_SIZE);

This used to work on my development machine (kernel 3.6.x), but now a
kernel 3.2.0 user reports a NULL pointer dereference of
hdspm->level_buffer, so apparently, snd_sgbuf_get_ptr() returned NULL
for him.

How could this possibly happen? Am I missing something? Better use


More information about the Alsa-devel mailing list