diff options
author | Alan Cox <alan@linux.intel.com> | 2012-12-20 18:05:24 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-20 20:40:19 -0500 |
commit | 5daa669c80c121ab75ecdf1c8e2df52f072fd25e (patch) | |
tree | 2b630dfed7fe5a88c1defe53dcdad10fee4d33f5 /fs | |
parent | 44fd07e989a9a27476d8963296688127a4fd4df4 (diff) |
hfsplus: avoid crash on failed block map free
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>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Jan Kara <jack@suse.cz>
Acked-by: Hin-Tak Leung <htl10@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/hfsplus/bitmap.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/fs/hfsplus/bitmap.c b/fs/hfsplus/bitmap.c index 4cfbe2edd296..6feefc0cb48a 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) | |||
176 | dprint(DBG_BITMAP, "block_free: %u,%u\n", offset, count); | 176 | dprint(DBG_BITMAP, "block_free: %u,%u\n", offset, count); |
177 | /* are all of the bits in range? */ | 177 | /* are all of the bits in range? */ |
178 | if ((offset + count) > sbi->total_blocks) | 178 | if ((offset + count) > sbi->total_blocks) |
179 | return -2; | 179 | return -ENOENT; |
180 | 180 | ||
181 | mutex_lock(&sbi->alloc_mutex); | 181 | mutex_lock(&sbi->alloc_mutex); |
182 | mapping = sbi->alloc_file->i_mapping; | 182 | mapping = sbi->alloc_file->i_mapping; |
183 | pnr = offset / PAGE_CACHE_BITS; | 183 | pnr = offset / PAGE_CACHE_BITS; |
184 | page = read_mapping_page(mapping, pnr, NULL); | 184 | page = read_mapping_page(mapping, pnr, NULL); |
185 | if (IS_ERR(page)) | ||
186 | goto kaboom; | ||
185 | pptr = kmap(page); | 187 | pptr = kmap(page); |
186 | curr = pptr + (offset & (PAGE_CACHE_BITS - 1)) / 32; | 188 | curr = pptr + (offset & (PAGE_CACHE_BITS - 1)) / 32; |
187 | end = pptr + PAGE_CACHE_BITS / 32; | 189 | end = pptr + PAGE_CACHE_BITS / 32; |
@@ -214,6 +216,8 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count) | |||
214 | set_page_dirty(page); | 216 | set_page_dirty(page); |
215 | kunmap(page); | 217 | kunmap(page); |
216 | page = read_mapping_page(mapping, ++pnr, NULL); | 218 | page = read_mapping_page(mapping, ++pnr, NULL); |
219 | if (IS_ERR(page)) | ||
220 | goto kaboom; | ||
217 | pptr = kmap(page); | 221 | pptr = kmap(page); |
218 | curr = pptr; | 222 | curr = pptr; |
219 | end = pptr + PAGE_CACHE_BITS / 32; | 223 | end = pptr + PAGE_CACHE_BITS / 32; |
@@ -232,4 +236,11 @@ out: | |||
232 | mutex_unlock(&sbi->alloc_mutex); | 236 | mutex_unlock(&sbi->alloc_mutex); |
233 | 237 | ||
234 | return 0; | 238 | return 0; |
239 | |||
240 | kaboom: | ||
241 | printk(KERN_CRIT "hfsplus: unable to mark blocks free: error %ld\n", | ||
242 | PTR_ERR(page)); | ||
243 | mutex_unlock(&sbi->alloc_mutex); | ||
244 | |||
245 | return -EIO; | ||
235 | } | 246 | } |