linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Question about commit f9a67b1182e5 ("md/bitmap: clear bitmap if bitmap_create failed").
@ 2016-09-12 19:09 Christophe JAILLET
  2016-09-13 17:24 ` Shaohua Li
  0 siblings, 1 reply; 5+ messages in thread
From: Christophe JAILLET @ 2016-09-12 19:09 UTC (permalink / raw)
  To: shli, linux-raid, linux-kernel

Hi,

I'm puzzled by commit f9a67b1182e5 ("md/bitmap: clear bitmap if 
bitmap_create failed").

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);


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, ...")


It is also not consistent with the comment before function bitmap_create():

     * if this returns an error, bitmap_destroy must be called to do 
clean up
     * once mddev->bitmap is set


I may have missed something, but I don't see what.

Is this commit correct?


Best regards,
CJ

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

end of thread, other threads:[~2016-09-18  9:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-12 19:09 Question about commit f9a67b1182e5 ("md/bitmap: clear bitmap if bitmap_create failed") Christophe JAILLET
2016-09-13 17:24 ` Shaohua Li
2016-09-14  8:25   ` Guoqing Jiang
2016-09-14 20:39     ` Marion & Christophe JAILLET
2016-09-18  9:19       ` Guoqing Jiang

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).