* [PATCH] block: fix memory leak of bvec
@ 2021-02-02 15:54 Ming Lei
2021-02-02 15:55 ` Christoph Hellwig
2021-02-02 15:58 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Ming Lei @ 2021-02-02 15:54 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Ming Lei, Christoph Hellwig, Johannes Thumshirn,
Chaitanya Kulkarni, Damien Le Moal
bio_init() clears bio instance, so the bvec index has to be set after
bio_init(), otherwise bio->bi_io_vec may be leaked.
Fixes: 3175199ab0ac ("block: split bio_kmalloc from bio_alloc_bioset")
Cc: Christoph Hellwig <hch@lst.de>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Cc: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/bio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/bio.c b/block/bio.c
index d4375619348c..757fee46cefc 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -482,8 +482,8 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned int nr_iovecs,
if (unlikely(!bvl))
goto err_free;
- bio->bi_flags |= idx << BVEC_POOL_OFFSET;
bio_init(bio, bvl, bvec_nr_vecs(idx));
+ bio->bi_flags |= idx << BVEC_POOL_OFFSET;
} else if (nr_iovecs) {
bio_init(bio, bio->bi_inline_vecs, BIO_INLINE_VECS);
} else {
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] block: fix memory leak of bvec
2021-02-02 15:54 [PATCH] block: fix memory leak of bvec Ming Lei
@ 2021-02-02 15:55 ` Christoph Hellwig
2021-02-02 15:58 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2021-02-02 15:55 UTC (permalink / raw)
To: Ming Lei
Cc: Jens Axboe, linux-block, Christoph Hellwig, Johannes Thumshirn,
Chaitanya Kulkarni, Damien Le Moal
On Tue, Feb 02, 2021 at 11:54:10PM +0800, Ming Lei wrote:
> bio_init() clears bio instance, so the bvec index has to be set after
> bio_init(), otherwise bio->bi_io_vec may be leaked.
Yeah, I've got exactly the same test sitting here as part of a larger
series:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] block: fix memory leak of bvec
2021-02-02 15:54 [PATCH] block: fix memory leak of bvec Ming Lei
2021-02-02 15:55 ` Christoph Hellwig
@ 2021-02-02 15:58 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2021-02-02 15:58 UTC (permalink / raw)
To: Ming Lei
Cc: linux-block, Christoph Hellwig, Johannes Thumshirn,
Chaitanya Kulkarni, Damien Le Moal
On 2/2/21 8:54 AM, Ming Lei wrote:
> bio_init() clears bio instance, so the bvec index has to be set after
> bio_init(), otherwise bio->bi_io_vec may be leaked.
Applied, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-02 16:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 15:54 [PATCH] block: fix memory leak of bvec Ming Lei
2021-02-02 15:55 ` Christoph Hellwig
2021-02-02 15:58 ` Jens Axboe
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.