From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: Allocating DMA buffer for non-PCM Date: Thu, 14 Feb 2013 18:14:00 +0100 Message-ID: References: <511D18F9.3040906@drcomp.erfurt.thur.de> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 6444726534F for ; Thu, 14 Feb 2013 18:14:01 +0100 (CET) In-Reply-To: <511D18F9.3040906@drcomp.erfurt.thur.de> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Adrian Knoth Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Thu, 14 Feb 2013 18:03:53 +0100, Adrian Knoth wrote: > > Hi! > > 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, > snd_dma_pci_data(hdspm->pci), > MADIFX_LEVEL_BUFFER_SIZE, &hdspm->dmaLevelBuffer); > if (err < 0) { > /* error */ [..] > } > > hdspm->level_buffer = snd_sgbuf_get_ptr(&(hdspm->dmaLevelBuffer), 0); hdspm->level_buffer = (u32*)hdspm.dmaLevelBuffer.area; > 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. What's level_buffer? Is a SG-buffer for the audio stream? > How could this possibly happen? A wrong usage :) Takashi > Am I missing something? Better use > SNDRV_DMA_TYPE_DEV instead? > > > > TIA > _______________________________________________ > Alsa-devel mailing list > Alsa-devel@alsa-project.org > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel >