* [PATCH] bio: Fix potential memory leak in bio_find_or_create_slab()
@ 2012-08-09 5:52 Alexey Khoroshilov
2012-08-09 13:15 ` Jeff Moyer
2012-08-09 13:19 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Alexey Khoroshilov @ 2012-08-09 5:52 UTC (permalink / raw)
To: Jens Axboe
Cc: Alexey Khoroshilov, Alexander Viro, linux-fsdevel, linux-kernel,
ldv-project
Do not leak memory by updating pointer with potentially NULL realloc return value.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
fs/bio.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/fs/bio.c b/fs/bio.c
index 5eaa70c..3fb4380 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -73,7 +73,7 @@ static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size)
{
unsigned int sz = sizeof(struct bio) + extra_size;
struct kmem_cache *slab = NULL;
- struct bio_slab *bslab;
+ struct bio_slab *bslab, *new_bio_slabs;
unsigned int i, entry = -1;
mutex_lock(&bio_slab_lock);
@@ -97,11 +97,12 @@ static struct kmem_cache *bio_find_or_create_slab(unsigned int extra_size)
if (bio_slab_nr == bio_slab_max && entry == -1) {
bio_slab_max <<= 1;
- bio_slabs = krealloc(bio_slabs,
- bio_slab_max * sizeof(struct bio_slab),
- GFP_KERNEL);
- if (!bio_slabs)
+ new_bio_slabs = krealloc(bio_slabs,
+ bio_slab_max * sizeof(struct bio_slab),
+ GFP_KERNEL);
+ if (!new_bio_slabs)
goto out_unlock;
+ bio_slabs = new_bio_slabs;
}
if (entry == -1)
entry = bio_slab_nr++;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] bio: Fix potential memory leak in bio_find_or_create_slab()
2012-08-09 5:52 [PATCH] bio: Fix potential memory leak in bio_find_or_create_slab() Alexey Khoroshilov
@ 2012-08-09 13:15 ` Jeff Moyer
2012-08-09 13:19 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Moyer @ 2012-08-09 13:15 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Jens Axboe, Alexander Viro, linux-fsdevel, linux-kernel,
ldv-project
Alexey Khoroshilov <khoroshilov@ispras.ru> writes:
> Do not leak memory by updating pointer with potentially NULL realloc return value.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Acked-by: Jeff Moyer <jmoyer@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bio: Fix potential memory leak in bio_find_or_create_slab()
2012-08-09 5:52 [PATCH] bio: Fix potential memory leak in bio_find_or_create_slab() Alexey Khoroshilov
2012-08-09 13:15 ` Jeff Moyer
@ 2012-08-09 13:19 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2012-08-09 13:19 UTC (permalink / raw)
To: Alexey Khoroshilov
Cc: Alexander Viro, linux-fsdevel, linux-kernel, ldv-project
On 08/09/2012 07:52 AM, Alexey Khoroshilov wrote:
> Do not leak memory by updating pointer with potentially NULL realloc return value.
>
> Found by Linux Driver Verification project (linuxtesting.org).
Thanks, applied.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-09 13:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-09 5:52 [PATCH] bio: Fix potential memory leak in bio_find_or_create_slab() Alexey Khoroshilov
2012-08-09 13:15 ` Jeff Moyer
2012-08-09 13:19 ` Jens Axboe
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).