lkml.org 
[lkml]   [2021]   [Oct]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [RFC PATCH 1/1] s390/cio: make ccw_device_dma_* more robust
    From


    On 10/11/21 16:33, Cornelia Huck wrote:
    > On Mon, Oct 11 2021, Pierre Morel <pmorel@linux.ibm.com> wrote:
    >
    >> On 10/11/21 1:59 PM, Halil Pasic wrote:
    >>> diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
    >>> index 0fe7b2f2e7f5..c533d1dadc6b 100644
    >>> --- a/drivers/s390/cio/device_ops.c
    >>> +++ b/drivers/s390/cio/device_ops.c
    >>> @@ -825,13 +825,23 @@ EXPORT_SYMBOL_GPL(ccw_device_get_chid);
    >>> */
    >>> void *ccw_device_dma_zalloc(struct ccw_device *cdev, size_t size)
    >>> {
    >>> - return cio_gp_dma_zalloc(cdev->private->dma_pool, &cdev->dev, size);
    >>> + void *addr;
    >>> +
    >>> + if (!get_device(&cdev->dev))
    >>> + return NULL;
    >>> + addr = cio_gp_dma_zalloc(cdev->private->dma_pool, &cdev->dev, size);
    >>> + if (IS_ERR_OR_NULL(addr))
    >>
    >> I can be wrong but it seems that only dma_alloc_coherent() used in
    >> cio_gp_dma_zalloc() report an error but the error is ignored and used as
    >> a valid pointer.
    >
    > Hm, I thought dma_alloc_coherent() returned either NULL or a valid
    > address?

    hum, my bad, checked the wrong function, should have use my glasses or
    connect my brain.

    >
    >>
    >> So shouldn't we modify this function and just test for a NULL address here?
    >
    > If I read cio_gp_dma_zalloc() correctly, we either get NULL or a valid
    > address, so yes.
    >

    --
    Pierre Morel
    IBM Lab Boeblingen

    \
     
     \ /
      Last update: 2021-10-12 16:12    [W:2.287 / U:0.068 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site