Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1482664

Re: Question about commit f9a67b1182e5 ("md/bitmap: clear bitmap if bitmap_create failed").

From Shaohua Li <shli@kernel.org>
Newsgroups linux.kernel
Subject Re: Question about commit f9a67b1182e5 ("md/bitmap: clear bitmap if bitmap_create failed").
Date 2016-09-13 19:30 +0200
Message-ID <sgZGW-4VC-17@gated-at.bofh.it> (permalink)
References <sgEVQ-7xR-47@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Sep 12, 2016 at 09:09:48PM +0200, Christophe JAILLET wrote:
> Hi,
> 
> I'm puzzled by commit f9a67b1182e5 ("md/bitmap: clear bitmap if
> bitmap_create failed").
Hi Christophe,
Thank you very much to help check this!

> Part of the commit is:
> 
> @@ -1865,8 +1866,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_free(bitmap);
>          return PTR_ERR(bitmap);
> +    }
> 
> but if 'bitmap' is an error, I think that bad things will happen in
> 'bitmap_free()' when, at the beginning of the function, we will execute:
> 
>     if (bitmap->sysfs_can_clear) <-----------------
>         sysfs_put(bitmap->sysfs_can_clear);

Add Guoqing.

Yeah, you are right, this bitmap_free isn't required. This must be something
slip in in the v2 patch. I'll delete that line.

> However, the commit log message is really explicit and adding this call to
> 'bitmap_free' has really been done one purpose. ("If bitmap_create returns
> an error, we need to call either bitmap_destroy or bitmap_free to do clean
> up, ...")

this log is a little confusing, I thought it really means the bitmap_free called
in bitmap_create. The V1 patch calls bitmap_destroy in bitmap_create.

Thanks,
Shaohua

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Question about commit f9a67b1182e5 ("md/bitmap: clear bitmap if  bitmap_create failed"). Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2016-09-12 21:20 +0200
  Re: Question about commit f9a67b1182e5 ("md/bitmap: clear bitmap if  bitmap_create failed"). Shaohua Li <shli@kernel.org> - 2016-09-13 19:30 +0200
    Re: Question about commit f9a67b1182e5 ("md/bitmap: clear bitmap if  bitmap_create failed"). Guoqing Jiang <gqjiang@suse.com> - 2016-09-14 10:30 +0200
      Re: Question about commit f9a67b1182e5 ("md/bitmap: clear bitmap if  bitmap_create failed"). Marion & Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2016-09-14 22:40 +0200
        Re: Question about commit f9a67b1182e5 ("md/bitmap: clear bitmap if  bitmap_create failed"). Guoqing Jiang <gqjiang@suse.com> - 2016-09-18 11:30 +0200

csiph-web