Re: [Intel-gfx] [PATCH v4] lib/scatterlist: Avoid potential scatterlist entry overflow

2017-01-16 Thread Andy Shevchenko
On Mon, Jan 16, 2017 at 12:05 PM, Tvrtko Ursulin wrote: > - for (i = 1; i < n_pages; ++i) > + for (i = 1; i < n_pages; ++i) { // Are compilers so stupid doing calculation per iteration in for-conditional? // for (i = 0; i + 1 < n_pages; i++) ? >>> I didn't get

Re: [Intel-gfx] [PATCH v4] lib/scatterlist: Avoid potential scatterlist entry overflow

2017-01-16 Thread Tvrtko Ursulin
On 13/01/2017 22:23, Andy Shevchenko wrote: @@ -402,9 +403,16 @@ int sg_alloc_table_from_pages(struct sg_table *sgt, /* compute number of contiguous chunks */ chunks = 1; - for (i = 1; i < n_pages; ++i) - if (page_to_pfn(pages[i]) != page_to_pfn(pages[i - 1])

Re: [Intel-gfx] [PATCH v4] lib/scatterlist: Avoid potential scatterlist entry overflow

2017-01-13 Thread Andy Shevchenko
>>> @@ -402,9 +403,16 @@ int sg_alloc_table_from_pages(struct sg_table *sgt, >>> >>> /* compute number of contiguous chunks */ >>> chunks = 1; >>> - for (i = 1; i < n_pages; ++i) >>> - if (page_to_pfn(pages[i]) != page_to_pfn(pages[i - 1]) + >>> 1) >>> + se

Re: [Intel-gfx] [PATCH v4] lib/scatterlist: Avoid potential scatterlist entry overflow

2017-01-13 Thread Tvrtko Ursulin
Hi, On 11/01/2017 23:59, Andy Shevchenko wrote: On Wed, Jan 11, 2017 at 1:58 PM, Tvrtko Ursulin wrote: Since the scatterlist length field is an unsigned int, make sure that sg_alloc_table_from_pages does not overflow it while coallescing pages to a single entry. /* + * Since the above le