lkml.org 
[lkml]   [2010]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] scatterlist: prevent invalid free when alloc fails
Hello,

On 08/27/2010 09:45 PM, Jeffrey Carlyle wrote:
>>> sg = alloc_fn(alloc_size, gfp_mask);
>>> - if (unlikely(!sg))
>>> + if (unlikely(!sg)) {
>>> + table->orig_nents = total_alloc;
>>> + /* mark the end of previous entry */
>>> + sg_mark_end(&prv[alloc_size - 1]);
>>
>> prv[alloc_size - 1] is already marked as end by sg_init_table() during
>> the previous iteration. Also, prv can be NULL at this point. AFAICS,
>> the only thing necessary would be "if (prv) table->nents++", no?
>
> You are right about prv possibly being NULL here. Sorry for not
> catching that earlier; however, I don't think prv will be marked as an
> end in the previous iteration.

But we have sg_mark_end(&sgl[nents-1]) in sg_init_table(). I think
explicit end marking in __sg_alloc_table() is redundant.

Thanks.

--
tejun


\
 
 \ /
  Last update: 2010-08-28 01:33    [W:0.065 / U:3.816 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site