Re: [PATCH] dma: fix error handling on out of memory

From: Dan Williams
Date: Wed Oct 13 2010 - 20:10:32 EST


On Mon, Oct 11, 2010 at 2:44 AM, Michael S. Tsirkin <mst@xxxxxxxxxx> wrote:
> get_user_pages might return less pages than requested. If this happens
> for the first iovec in dma_pin_iovec_pages, then nr_iovecs is 0 and so
> dma_unpin_iovec_pages will not unpin any pages, leaking pinned memory.
> A similar off by one would trigger for any of the following entries.
>
> Fix by updating nr_iovecs and nr_pages in this case.
>
> Signed-off-by: Michael S. Tsirkin <mst@xxxxxxxxxx>
> ---
>
> Error handling in dma_pin_iovec_pages still looks wrong to me.  Am I
> missing something?

Still looks wrong it what way? You make sure that nr_iovecs is
incremented so that the partial page list is freed, and we only walk
the initialized entries in pinned_list.

--
Dan
--
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/