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- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sat Jun 15 2002 - 22:00:23 EST