lkml.org 
[lkml]   [2002]   [Jun]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: PCI DMA to small buffers on cache-incoherent arch
    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/

    \
     
     \ /
      Last update: 2005-03-22 13:26    [W:0.023 / U:93.568 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site