linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] hfsplus: avoid crash on failed block map free
@ 2012-11-13  9:31 Vyacheslav Dubeyko
  2012-11-13 22:34 ` Andrew Morton
  0 siblings, 1 reply; 13+ messages in thread
From: Vyacheslav Dubeyko @ 2012-11-13  9:31 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-fsdevel, Andrew Morton

Hi Alan,

Do you agree with second version of the patch?

With the best regards,
Vyacheslav Dubeyko.
--
From: Alan Cox <alan@linux.intel.com>
Subject: [PATCH v2] hfsplus: avoid crash on failed block map free

v1->v2
* Change hardcoded error code on -ENOENT.
* Add return -EIO for the case of kmap error.
* Fix issue with twice mutex unlock.
* Fix issue with printing kmap error message on every call.

If the read fails we kmap an error code. This doesn't end well. Instead print a critical error and pray. This mirrors the rest of the fs behaviour with critical error cases.

Acked-by: Vyacheslav Dubeyko <slava@dubeyko.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Vyacheslav Dubeyko <slava@dubeyko.com>
---
 fs/hfsplus/bitmap.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/fs/hfsplus/bitmap.c b/fs/hfsplus/bitmap.c
index 4cfbe2e..6feefc0 100644
--- a/fs/hfsplus/bitmap.c
+++ b/fs/hfsplus/bitmap.c
@@ -176,12 +176,14 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
 	dprint(DBG_BITMAP, "block_free: %u,%u\n", offset, count);
 	/* are all of the bits in range? */
 	if ((offset + count) > sbi->total_blocks)
-		return -2;
+		return -ENOENT;
 
 	mutex_lock(&sbi->alloc_mutex);
 	mapping = sbi->alloc_file->i_mapping;
 	pnr = offset / PAGE_CACHE_BITS;
 	page = read_mapping_page(mapping, pnr, NULL);
+	if (IS_ERR(page))
+		goto kaboom;
 	pptr = kmap(page);
 	curr = pptr + (offset & (PAGE_CACHE_BITS - 1)) / 32;
 	end = pptr + PAGE_CACHE_BITS / 32;
@@ -214,6 +216,8 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count)
 		set_page_dirty(page);
 		kunmap(page);
 		page = read_mapping_page(mapping, ++pnr, NULL);
+		if (IS_ERR(page))
+			goto kaboom;
 		pptr = kmap(page);
 		curr = pptr;
 		end = pptr + PAGE_CACHE_BITS / 32;
@@ -232,4 +236,11 @@ out:
 	mutex_unlock(&sbi->alloc_mutex);
 
 	return 0;
+
+kaboom:
+	printk(KERN_CRIT "hfsplus: unable to mark blocks free: error %ld\n",
+			PTR_ERR(page));
+	mutex_unlock(&sbi->alloc_mutex);
+
+	return -EIO;
 }
-- 
1.7.9.5




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

end of thread, other threads:[~2012-12-19 14:16 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-13  9:31 [PATCH v2] hfsplus: avoid crash on failed block map free Vyacheslav Dubeyko
2012-11-13 22:34 ` Andrew Morton
2012-11-14 11:24   ` Christoph Hellwig
2012-11-15  7:07     ` Vyacheslav Dubeyko
2012-11-15  9:17       ` Christoph Hellwig
2012-11-15  9:31         ` Vyacheslav Dubeyko
2012-11-14 12:50   ` Vyacheslav Dubeyko
2012-12-18 22:47     ` Andrew Morton
2012-12-19  6:26       ` Vyacheslav Dubeyko
2012-12-19  6:29         ` Andrew Morton
2012-12-19  6:42           ` Vyacheslav Dubeyko
2012-12-19 14:09             ` Christoph Hellwig
2012-12-19 14:15               ` Vyacheslav Dubeyko

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