Re: [PATCH] scatterlist: prevent invalid free when alloc fails

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jeffrey Carlyle
Date: Friday, August 27, 2010 - 12:45 pm

On Fri, Aug 27, 2010 at 5:18 AM, Tejun Heo <tj@kernel.org> wrote:

Sorry about that.


Well the problem we were seeing manifested itself when we called
free_fn on a NULL value. This was a naive attempt at avoiding that. If
the logic in __sg_alloc_table is corrected, I agree that we shouldn't
need this.


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. According to my read it will only get
marked if left is equal to 0, in which case the while loop exits.
Perhaps something like this would be more appropriate:

if(prv) {
        table->orig_nents = ++table->nents;
        sg_mark_end(&prv[alloc_size - 1]);
}

Thank you for taking the time to review this.
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] scatterlist: prevent invalid free when alloc fails, Jeffrey Carlyle, (Thu Aug 26, 9:04 am)
Re: [PATCH] scatterlist: prevent invalid free when alloc fails, Jeffrey Carlyle, (Fri Aug 27, 12:45 pm)