All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guoqing Jiang <gqjiang@suse.com>
To: Shaohua Li <shli@kernel.org>
Cc: linux-raid@vger.kernel.org, neilb@suse.com
Subject: Re: [PATCH] md/bitmap: call bitmap_destroy in case bitmap_create failed
Date: Mon, 28 Mar 2016 11:27:26 +0800	[thread overview]
Message-ID: <56F8A49E.60705@suse.com> (raw)
In-Reply-To: <20160325220210.GA78806@kernel.org>



On 03/26/2016 06:02 AM, Shaohua Li wrote:
> On Fri, Mar 25, 2016 at 07:00:14PM +0800, Guoqing Jiang wrote:
>> If bitmap_create returns an error, bitmap_destroy must be
>> called to do clean up.
>>
>> Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
>> ---
>>   drivers/md/bitmap.c | 14 ++++++++------
>>   1 file changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
>> index 7df6b4f..ba908e7 100644
>> --- a/drivers/md/bitmap.c
>> +++ b/drivers/md/bitmap.c
>> @@ -1865,8 +1865,10 @@ int bitmap_copy_from_slot(struct mddev *mddev, int slot,
>>   	struct bitmap_counts *counts;
>>   	struct bitmap *bitmap = bitmap_create(mddev, slot);
>>   
>> -	if (IS_ERR(bitmap))
>> +	if (IS_ERR(bitmap)) {
>> +		bitmap_destroy(mddev);
>>   		return PTR_ERR(bitmap);
>> +	}
> bitmap_create doesn't set mddev->bitmap, so bitmap_destroy will do nothing.
> is this because of reference leak of sysfs_can_clear?

Yes, use bitmap_free should be ok here since mddev->bitmap is not set.

> can we move sysfs_put(bitmap->sysfs_can_clear); to bitmap_free?

Do you mean move sysfs_put from bitmap_destroy to bitmap_free?
I guess it could be ok. Also we need make minor change to the comment.

/*
   * initialize the bitmap structure
   * if this returns an error, bitmap_destroy must be called to do clean up
+ * once mddev->bitmap is set
   */
  struct bitmap *bitmap_create(struct mddev *mddev, int slot)

Thanks,
Guoqing


  reply	other threads:[~2016-03-28  3:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-25 11:00 [PATCH] md/bitmap: call bitmap_destroy in case bitmap_create failed Guoqing Jiang
2016-03-25 22:02 ` Shaohua Li
2016-03-28  3:27   ` Guoqing Jiang [this message]
2016-03-28 18:15     ` Shaohua Li
2016-04-01  9:08 ` [V2 PATCH] md/bitmap: clear bitmap if " Guoqing Jiang
2016-04-01 20:04   ` Shaohua Li

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=56F8A49E.60705@suse.com \
    --to=gqjiang@suse.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.com \
    --cc=shli@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 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.