lkml.org 
[lkml]   [2019]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [RFC][PATCH 2/5 v2] dma-buf: heaps: Add heap helpers
    On Tue, Mar 19, 2019 at 7:26 AM Brian Starkey <Brian.Starkey@arm.com> wrote:
    >
    > Hi John,
    >
    > On Tue, Mar 05, 2019 at 12:54:30PM -0800, John Stultz wrote:
    >
    > ...
    >
    > > +
    > > +void dma_heap_buffer_destroy(struct dma_heap_buffer *heap_buffer)
    > > +{
    > > + struct heap_helper_buffer *buffer = to_helper_buffer(heap_buffer);
    > > +
    > > + if (buffer->kmap_cnt > 0) {
    > > + pr_warn_once("%s: buffer still mapped in the kernel\n",
    > > + __func__);
    >
    > Could be worth something louder like a full WARN.
    >
    > > + vunmap(buffer->vaddr);
    > > + }
    > > +
    > > + buffer->free(buffer);
    > > +}
    > > +
    >
    > ...
    >
    > > +
    > > +static void *dma_heap_dma_buf_kmap(struct dma_buf *dmabuf,
    > > + unsigned long offset)
    > > +{
    > > + struct dma_heap_buffer *heap_buffer = dmabuf->priv;
    > > + struct heap_helper_buffer *buffer = to_helper_buffer(heap_buffer);
    > > +
    > > + return buffer->vaddr + offset * PAGE_SIZE;
    >
    > I think it'd be good to check for NULL vaddr and return NULL in that
    > case. Less chance of an invalid pointer being accidentally used then.

    Thanks so much for the feedback! I've added these two suggestions in!
    -john

    \
     
     \ /
      Last update: 2019-03-21 21:12    [W:4.181 / U:0.536 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site