Re: [PATCH] ib: don't doublefree pages from scatterlist

From: Roland Dreier
Date: Fri Feb 03 2006 - 18:12:05 EST


Thanks, Hugh. This is definitely a real bug caused by an embarassing
oversight on my part. I will test and apply to my trees.

> Warning: untested! And please double-check the adjusted definition of
> IB_UMEM_MAX_PAGE_CHUNK - the old definition was avoiding "sizeof"s, but
> I don't understand why.

The old definition of IB_UMEM_MAX_PAGE_CHUNK came from my paranoia:

> #define IB_UMEM_MAX_PAGE_CHUNK \
> ((PAGE_SIZE - offsetof(struct ib_umem_chunk, page_list)) / \
> - ((void *) &((struct ib_umem_chunk *) 0)->page_list[1] - \
> - (void *) &((struct ib_umem_chunk *) 0)->page_list[0]))
> + (sizeof(struct scatterlist) + sizeof(struct page *)))

I was afraid that some compiler somewhere might add in some padding
that would cause sizeof (struct scatterlist) to be smaller than the
entries in the array end up being, but now I've convinced myself that
this can't happen -- if it could then things like ARRAY_SIZE() would
be stuffed as well.

So I think your version is correct and clearer.

Thanks,
Roland
-
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/