fs/ntfs/mft.c:471:33: warning: Variable length array is used. fs/ntfs/mft.c:676:33: warning: Variable length array is used.
This is untested. Cc: Anton Altaparmakov <an...@tuxera.com> Cc: Andrew Morton <a...@linux-foundation.org> Signed-off-by: Fabian Frederick <f...@skynet.be> --- fs/ntfs/mft.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/fs/ntfs/mft.c b/fs/ntfs/mft.c index 3014a36..eddb739 100644 --- a/fs/ntfs/mft.c +++ b/fs/ntfs/mft.c @@ -468,7 +468,7 @@ int ntfs_sync_mft_mirror(ntfs_volume *vol, const unsigned long mft_no, struct page *page; unsigned int blocksize = vol->sb->s_blocksize; int max_bhs = vol->mft_record_size / blocksize; - struct buffer_head *bhs[max_bhs]; + struct buffer_head **bhs; struct buffer_head *bh, *head; u8 *kmirr; runlist_element *rl; @@ -478,11 +478,14 @@ int ntfs_sync_mft_mirror(ntfs_volume *vol, const unsigned long mft_no, ntfs_debug("Entering for inode 0x%lx.", mft_no); BUG_ON(!max_bhs); - if (unlikely(!vol->mftmirr_ino)) { + bhs = kmalloc(max_bhs * sizeof(struct buffer_head *), GFP_NOFS); + if (unlikely(!bhs || !vol->mftmirr_ino)) { /* This could happen during umount... */ err = ntfs_sync_mft_mirror_umount(vol, mft_no, m); - if (likely(!err)) + if (likely(!err)) { + kfree(bhs); return err; + } goto err_out; } /* Get the page containing the mirror copy of the mft record @m. */ @@ -632,6 +635,7 @@ err_out: "after umounting to correct this.", -err); NVolSetErrors(vol); } + kfree(bhs); return err; } @@ -673,7 +677,7 @@ int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync) unsigned int blocksize = vol->sb->s_blocksize; unsigned char blocksize_bits = vol->sb->s_blocksize_bits; int max_bhs = vol->mft_record_size / blocksize; - struct buffer_head *bhs[max_bhs]; + struct buffer_head **bhs; struct buffer_head *bh, *head; runlist_element *rl; unsigned int block_start, block_end, m_start, m_end; @@ -689,7 +693,8 @@ int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync) * There is no danger of races since the caller is holding the locks * for the mft record @m and the page it is in. */ - if (!NInoTestClearDirty(ni)) + bhs = kmalloc(max_bhs * sizeof(struct buffer_head *), GFP_NOFS); + if (!bhs || !NInoTestClearDirty(ni)) goto done; bh = head = page_buffers(page); BUG_ON(!bh); @@ -820,6 +825,7 @@ int write_mft_record_nolock(ntfs_inode *ni, MFT_RECORD *m, int sync) goto err_out; } done: + kfree(bhs); ntfs_debug("Done."); return 0; cleanup_out: @@ -840,6 +846,7 @@ err_out: err = 0; } else NVolSetErrors(vol); + kfree(bhs); return err; } -- 1.8.4.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/