On Thu, Nov 09, 2017 at 02:37:29PM +0000, Horia Geantă wrote: > > >> sg_init_table(sg, np + 1); > sg_mark_end() marks sg[np]. > > >> - np--; > >> + if (rem) > >> + np--; > >> for (k = 0; k < np; k++) > >> sg_set_buf(&sg[k + 1], xbuf[k], PAGE_SIZE); > In case rem == 0, last k value is np-1, thus sg[np-1+1] will be filled > here with xbuf[np-1]. No, if rem == 0, then the last k value is np-2. The whole point of the patch is to shrink the SG table by one entry when rem == 0. How can you shrink it without moving the end-of-table marker? Cheers, -- Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt