From: Mike Snitzer <snitzer@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>,
James.Bottomley@suse.de, axboe@kernel.dk,
linux-scsi@vger.kernel.org, dm-devel@redhat.com,
linux-kernel@vger.kernel.org
Subject: Re: scsi: address leak in the error path of discard page allocation
Date: Fri, 2 Jul 2010 09:08:56 -0400 [thread overview]
Message-ID: <20100702130855.GA6058@redhat.com> (raw)
In-Reply-To: <20100702105241.GD26318@lst.de>
On Fri, Jul 02 2010 at 6:52am -0400,
Christoph Hellwig <hch@lst.de> wrote:
> On Fri, Jul 02, 2010 at 01:53:14PM +0900, FUJITA Tomonori wrote:
> > Seems that scsi-ml calls scsi_unprep_request() for not-prepped
> > requests in scsi_init_io error path. So we could move that
> > scsi_unprep_request() to the error path in scsi_prep_return(). Then we
> > can free discard page in the single place.
> >
> > Applying the rule strictly is fine by me too; we remove
> > scsi_unprep_request() in scsi_init_io error path and clean up things
> > in each prep function's error path.
>
> That would be my preference. Making sure a function cleans up all
> allocations / state changes on errors means code is a lot fragile and
> easier to understand.
>
> > Btw, blk_clear_request_payload() is necessary?
> >
> > Making sure that a request is clean is not a bad idea but if we hit
> > BLKPREP_KILL or BLKPREP_DEFER, we call
> > blk_end_request(). blk_end_request() can free a request properly even
> > if we don't do something like blk_clear_request_payload?
>
> For BLKPREP_KILL we do call __blk_end_request_all, but for
> BLKPREP_DEFER we don't. In that case we just leave it on the queue for
> a later retry. So we either have to clean it up, or leave the detect
> the case of a partially constructed command in ->prep_fn. I think
> cleaning up properly and having defined state when entering ->prep_fn is
> the better variant.
Right, I shared the same opinion earlier in this thread, so please let
your ACKs fly now that we seem to all be in agreement.
I'd like Jens to pick this patch up now-ish ;)
Mike
next prev parent reply other threads:[~2010-07-02 13:09 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-01 10:49 (unknown) FUJITA Tomonori
2010-07-01 10:49 ` [PATCH 1/3] block: implement an unprep function corresponding directly to prep FUJITA Tomonori
2010-07-01 13:30 ` James Bottomley
2010-07-01 10:49 ` [PATCH 2/3] scsi: add sd_unprep_fn to free discard page FUJITA Tomonori
2010-07-01 13:03 ` [PATCH] scsi: address leak in the error path of discard page allocation Mike Snitzer
2010-07-01 20:15 ` Mike Snitzer
2010-07-01 20:19 ` James Bottomley
2010-07-01 21:07 ` Mike Snitzer
2010-07-02 10:49 ` Christoph Hellwig
2010-07-02 4:53 ` FUJITA Tomonori
2010-07-02 10:52 ` Christoph Hellwig
2010-07-02 13:08 ` Mike Snitzer [this message]
2010-07-05 4:00 ` FUJITA Tomonori
2010-07-02 10:48 ` [PATCH] " Christoph Hellwig
2010-07-02 10:48 ` [PATCH 2/3] scsi: add sd_unprep_fn to free discard page Christoph Hellwig
2010-07-05 10:07 ` Boaz Harrosh
2010-07-01 10:49 ` [PATCH 3/3] scsi: remove unused free discard page in sd_done FUJITA Tomonori
2010-07-02 10:52 ` Christoph Hellwig
2010-07-01 12:29 ` Jens Axboe
2010-07-01 13:40 ` add sd_unprep_fn to free discard page Boaz Harrosh
2010-07-01 13:57 ` James Bottomley
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=20100702130855.GA6058@redhat.com \
--to=snitzer@redhat.com \
--cc=James.Bottomley@suse.de \
--cc=axboe@kernel.dk \
--cc=dm-devel@redhat.com \
--cc=fujita.tomonori@lab.ntt.co.jp \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.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).