Index: uspace/lib/ext4/libext4_ialloc.c
===================================================================
--- uspace/lib/ext4/libext4_ialloc.c	(revision e5a1ace31a3fced247ff6f421a3de1c6328973e8)
+++ uspace/lib/ext4/libext4_ialloc.c	(revision a17cced459351c09ce76e034323992c244cd80e6)
@@ -204,6 +204,8 @@
 			rc = block_get(&bitmap_block, fs->device, bitmap_block_addr,
 			    BLOCK_FLAGS_NONE);
-			if (rc != EOK)
+			if (rc != EOK) {
+				ext4_filesystem_put_block_group_ref(bg_ref);
 				return rc;
+			}
 			
 			/* Try to allocate i-node in the bitmap */
@@ -225,4 +227,5 @@
 					return rc;
 
+				bgid++;
 				continue;
 			}
@@ -232,6 +235,8 @@
 			
 			rc = block_put(bitmap_block);
-			if (rc != EOK)
+			if (rc != EOK) {
+				ext4_filesystem_put_block_group_ref(bg_ref);
 				return rc;
+			}
 			
 			/* Modify filesystem counters */
