From: Tejun Heo <tj@kernel.org>
To: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Cc: torvalds@osdl.org, linux-kernel@vger.kernel.org,
jaxboe@fusionio.com,
OLUSANYA SOYANNWO <olusanya.soyannwo@motorola.com>,
Hu Tao <taohu@motorola.com>
Subject: Re: [PATCH] scatterlist: prevent invalid free when alloc fails
Date: Sat, 28 Aug 2010 01:32:20 +0200 [thread overview]
Message-ID: <4C784B04.7060604@kernel.org> (raw)
In-Reply-To: <AANLkTinZLdSTVenJ=ShK9-f27eMQSyv=j6vYK+F3K96s@mail.gmail.com>
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
next prev parent reply other threads:[~2010-08-27 23:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-26 16:04 [PATCH] scatterlist: prevent invalid free when alloc fails Jeffrey Carlyle
2010-08-27 10:18 ` Tejun Heo
2010-08-27 19:45 ` Jeffrey Carlyle
2010-08-27 20:15 ` Jeffrey Carlyle
2010-08-27 23:32 ` Tejun Heo [this message]
2010-08-30 15:01 ` [PATCH v2] " Jeffrey Carlyle
2010-08-30 15:58 ` [PATCH v3] " Jeffrey Carlyle
2010-08-30 16:04 ` [PATCH v4] " Jeffrey Carlyle
2010-08-30 16:08 ` [PATCH v5] " Jeffrey Carlyle
2010-08-30 16:13 ` Tejun Heo
2010-08-30 16:19 ` [PATCH v6] " Jeffrey Carlyle
2010-08-30 17:28 ` Tejun Heo
2010-08-30 17:56 ` Jens Axboe
2010-08-30 16:05 ` [PATCH v3] " Tejun Heo
2010-08-30 16:12 ` Jeffrey Carlyle
2010-08-30 16:00 ` [PATCH v2] " Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C784B04.7060604@kernel.org \
--to=tj@kernel.org \
--cc=jaxboe@fusionio.com \
--cc=jeff.carlyle@motorola.com \
--cc=linux-kernel@vger.kernel.org \
--cc=olusanya.soyannwo@motorola.com \
--cc=taohu@motorola.com \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).