Linux-Raid Archives on lore.kernel.org
 help / color / Atom feed
* [PATCH] [md-cluster] fix memory leak for bitmap
@ 2020-09-27  5:40 Zhao Heming
  2020-10-08  3:36 ` Guoqing Jiang
  0 siblings, 1 reply; 4+ messages in thread
From: Zhao Heming @ 2020-09-27  5:40 UTC (permalink / raw)
  To: linux-raid, song; +Cc: Zhao Heming, guoqing.jiang

current code doesn't free temporary bitmap memory.

Signed-off-by: Zhao Heming <heming.zhao@suse.com>
---
 drivers/md/md-bitmap.c  | 1 +
 drivers/md/md-cluster.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index b10c519..593fe15 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2012,6 +2012,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
 	md_bitmap_unplug(mddev->bitmap);
 	*low = lo;
 	*high = hi;
+	md_bitmap_free(bitmap);
 
 	return rv;
 }
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index d50737e..afbbc55 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1166,6 +1166,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
 			 * can't resize bitmap
 			 */
 			goto out;
+		md_bitmap_free(bitmap);
 	}
 
 	return 0;
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [md-cluster] fix memory leak for bitmap
  2020-09-27  5:40 [PATCH] [md-cluster] fix memory leak for bitmap Zhao Heming
@ 2020-10-08  3:36 ` Guoqing Jiang
  2020-10-08  6:56   ` Song Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Guoqing Jiang @ 2020-10-08  3:36 UTC (permalink / raw)
  To: Zhao Heming, linux-raid, song



On 9/27/20 07:40, Zhao Heming wrote:
> current code doesn't free temporary bitmap memory.
>
> Signed-off-by: Zhao Heming <heming.zhao@suse.com>
> ---
>   drivers/md/md-bitmap.c  | 1 +
>   drivers/md/md-cluster.c | 1 +
>   2 files changed, 2 insertions(+)
>
> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
> index b10c519..593fe15 100644
> --- a/drivers/md/md-bitmap.c
> +++ b/drivers/md/md-bitmap.c
> @@ -2012,6 +2012,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
>   	md_bitmap_unplug(mddev->bitmap);
>   	*low = lo;
>   	*high = hi;
> +	md_bitmap_free(bitmap);
>   
>   	return rv;
>   }
> diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
> index d50737e..afbbc55 100644
> --- a/drivers/md/md-cluster.c
> +++ b/drivers/md/md-cluster.c
> @@ -1166,6 +1166,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
>   			 * can't resize bitmap
>   			 */
>   			goto out;
> +		md_bitmap_free(bitmap);
>   	}
>   
>   	return 0;

I'd prefer add a comment for get_bitmap_from_slot to mention it's caller 
need to
free bitmap.

Thanks,
Guoqing

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [md-cluster] fix memory leak for bitmap
  2020-10-08  3:36 ` Guoqing Jiang
@ 2020-10-08  6:56   ` Song Liu
  2020-10-08 10:35     ` heming.zhao
  0 siblings, 1 reply; 4+ messages in thread
From: Song Liu @ 2020-10-08  6:56 UTC (permalink / raw)
  To: Guoqing Jiang; +Cc: Zhao Heming, linux-raid

On Wed, Oct 7, 2020 at 8:36 PM Guoqing Jiang
<guoqing.jiang@cloud.ionos.com> wrote:
>
>
>
> On 9/27/20 07:40, Zhao Heming wrote:
> > current code doesn't free temporary bitmap memory.
> >
> > Signed-off-by: Zhao Heming <heming.zhao@suse.com>
> > ---
> >   drivers/md/md-bitmap.c  | 1 +
> >   drivers/md/md-cluster.c | 1 +
> >   2 files changed, 2 insertions(+)
> >
> > diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
> > index b10c519..593fe15 100644
> > --- a/drivers/md/md-bitmap.c
> > +++ b/drivers/md/md-bitmap.c
> > @@ -2012,6 +2012,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
> >       md_bitmap_unplug(mddev->bitmap);
> >       *low = lo;
> >       *high = hi;
> > +     md_bitmap_free(bitmap);
> >
> >       return rv;
> >   }
> > diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
> > index d50737e..afbbc55 100644
> > --- a/drivers/md/md-cluster.c
> > +++ b/drivers/md/md-cluster.c
> > @@ -1166,6 +1166,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
> >                        * can't resize bitmap
> >                        */
> >                       goto out;
> > +             md_bitmap_free(bitmap);
> >       }
> >
> >       return 0;
>
> I'd prefer add a comment for get_bitmap_from_slot to mention it's caller
> need to
> free bitmap.

I added comment to the patch with Guoqing's "Suggested-by" tag, and applied
it to md-next. I also made some changes to the commit log of all 3 patches from
Heming.

Herming, for future patches, please prefix the subject with "md:" or
"md/bitmap".

Thanks,
Song

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [md-cluster] fix memory leak for bitmap
  2020-10-08  6:56   ` Song Liu
@ 2020-10-08 10:35     ` heming.zhao
  0 siblings, 0 replies; 4+ messages in thread
From: heming.zhao @ 2020-10-08 10:35 UTC (permalink / raw)
  To: Song Liu, Guoqing Jiang; +Cc: linux-raid

Hello Song & Guoqing,

Thank you for your review.
I will take your advises & take more attention on later.

On 10/8/20 2:56 PM, Song Liu wrote:
> On Wed, Oct 7, 2020 at 8:36 PM Guoqing Jiang
> <guoqing.jiang@cloud.ionos.com> wrote:
>>
>>
>>
>> On 9/27/20 07:40, Zhao Heming wrote:
>>> current code doesn't free temporary bitmap memory.
>>>
>>> Signed-off-by: Zhao Heming <heming.zhao@suse.com>
>>> ---
>>>    drivers/md/md-bitmap.c  | 1 +
>>>    drivers/md/md-cluster.c | 1 +
>>>    2 files changed, 2 insertions(+)
>>>
>>> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
>>> index b10c519..593fe15 100644
>>> --- a/drivers/md/md-bitmap.c
>>> +++ b/drivers/md/md-bitmap.c
>>> @@ -2012,6 +2012,7 @@ int md_bitmap_copy_from_slot(struct mddev *mddev, int slot,
>>>        md_bitmap_unplug(mddev->bitmap);
>>>        *low = lo;
>>>        *high = hi;
>>> +     md_bitmap_free(bitmap);
>>>
>>>        return rv;
>>>    }
>>> diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
>>> index d50737e..afbbc55 100644
>>> --- a/drivers/md/md-cluster.c
>>> +++ b/drivers/md/md-cluster.c
>>> @@ -1166,6 +1166,7 @@ static int resize_bitmaps(struct mddev *mddev, sector_t newsize, sector_t oldsiz
>>>                         * can't resize bitmap
>>>                         */
>>>                        goto out;
>>> +             md_bitmap_free(bitmap);
>>>        }
>>>
>>>        return 0;
>>
>> I'd prefer add a comment for get_bitmap_from_slot to mention it's caller
>> need to
>> free bitmap.
> 
> I added comment to the patch with Guoqing's "Suggested-by" tag, and applied
> it to md-next. I also made some changes to the commit log of all 3 patches from
> Heming.
> 
> Herming, for future patches, please prefix the subject with "md:" or
> "md/bitmap".
> 
> Thanks,
> Song
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-27  5:40 [PATCH] [md-cluster] fix memory leak for bitmap Zhao Heming
2020-10-08  3:36 ` Guoqing Jiang
2020-10-08  6:56   ` Song Liu
2020-10-08 10:35     ` heming.zhao

Linux-Raid Archives on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-raid/0 linux-raid/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-raid linux-raid/ https://lore.kernel.org/linux-raid \
		linux-raid@vger.kernel.org
	public-inbox-index linux-raid

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-raid


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git