From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alan Cox Subject: [PATCH] hfsplus: avoid crash on failed block map free Date: Tue, 30 Oct 2012 14:23:45 +0000 Message-ID: <20121030142341.29261.25317.stgit@bob.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: linux-fsdevel@vger.kernel.org Return-path: Received: from lxorguk.ukuu.org.uk ([81.2.110.251]:59611 "EHLO lxorguk.ukuu.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751149Ab2J3OVv (ORCPT ); Tue, 30 Oct 2012 10:21:51 -0400 Received: from bob.linux.org.uk (earthlight.etchedpixels.co.uk [81.2.110.250]) by lxorguk.ukuu.org.uk (8.14.5/8.14.1) with ESMTP id q9UErhYO023316 for ; Tue, 30 Oct 2012 14:53:51 GMT Sender: linux-fsdevel-owner@vger.kernel.org List-ID: From: Alan Cox 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. Signed-off-by: Alan Cox --- fs/hfsplus/bitmap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/hfsplus/bitmap.c b/fs/hfsplus/bitmap.c index 4cfbe2e..5eeefee 100644 --- a/fs/hfsplus/bitmap.c +++ b/fs/hfsplus/bitmap.c @@ -182,6 +182,8 @@ int hfsplus_block_free(struct super_block *sb, u32 offset, u32 count) 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; @@ -231,5 +235,9 @@ out: hfsplus_mark_mdb_dirty(sb); mutex_unlock(&sbi->alloc_mutex); +kaboom: + printk(KERN_CRIT "hfsplus: unable to mark blocks free: error %ld\n", + PTR_ERR(page)); + mutex_unlock(&sbi->alloc_mutex); return 0; }