Re: [PATCH] asm-generic: add a dma-mapping.h file

From: Arnd Bergmann
Date: Mon May 18 2009 - 04:29:47 EST


On Monday 18 May 2009, Geert Uytterhoeven wrote:

> > +#ifndef dma_alloc_coherent
> > +static inline void *
> > +dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
> > + Â Â Â Â Â Â Â Â Âgfp_t flag)
> > +{
> > + Â Â Â void *virt = kmalloc(size, flag);
>
> kmalloc() may fail.
>
> > + Â Â Â *dma_handle = virt_to_phys(virt);
>
> Not all variants of virt_to_phys() may handle the NULL case very well.
> I took a statistically invalid sample: some just cast to unsigned
> long, other subtract PAGE_OFFSET.

Right. It should not really hurt, because all users need to check virt
before using dma_handle, but I can fix it just to be sure.

I'll wait for comments from Fujita Tomonori and others before I repost.

Arnd <><
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/