Re: PCI DMA to small buffers on cache-incoherent arch

Thunder from the hill
2002-06-11T23:01:13Z

Hi,

On 11 Jun 2002, Roland Dreier wrote:
> 3) Change the code to
>
> struct something {
> int field1;
> char *dma_buffer;
> int field2;
> };
>
> struct something *dev = kmalloc(sizeof *dev, GFP_KERNEL);
> /* find pci_device */
> dev->dma_buffer = aligned_pci_alloc(pci_device, SMALLER_THAN_CACHELINE);
> /* do DMA into dev->dma_buffer */

You introduce a possible null pointer dereference here, don't you?

// Assume this fails:
struct something *dev = kmalloc(sizeof(struct something), GFP_KERNEL);
// dev is a NULL pointer now.
dev->dma_buffer = aligned_pci_alloc(pci_device, SMALLER_THAN_CACHELINE);
// Big bang

Just wondering...

Regards,
Thunder
--
German attitude becoming | Thunder from the hill at ngforever
rightaway popular: |
"Get outa my way, | free inhabitant not directly
for I got a mobile phone!" | belonging anywhere