vfs: Don't call attach_nobh_buffers() with an empty list
vfs: Don't call attach_nobh_buffers() with an empty list

This is a modification of a patch by Bill Pemberton <6208e3c588e4690c7dfac5e95777d6a902c5fb27@virginia.edu>

nobh_write_end() could call attach_nobh_buffers() with head == NULL.
This would result in a trap when attach_nobh_buffers() attempted to
access bh->b_this_page.

This can be illustrated by running the writev01 testcase from LTP on jfs.

This error was introduced by commit 5b41e74a "vfs: fix data leak in
nobh_write_end()".  That patch did not take into account that if
PageMappedToDisk() is true upon entry to nobh_write_begin(), then no
buffers will be allocated for the page.  In that case, we won't have to
worry about a failed write leaving unitialized data in the page.

Of course, head != NULL implies !page_has_buffers(page), so no need to
test both.

Signed-off-by: Dave Kleikamp <9bc4ae2e83dabb4524fc335d7c1dac408a99dbe5@linux.vnet.ibm.com>
Cc: Bill Pemberton <6208e3c588e4690c7dfac5e95777d6a902c5fb27@virginia.edu>
Cc: Dmitri Monakhov <eecfa5af1016ca9db755569d9919e212ab6a1c94@openvz.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,KristFoundation/Programs,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,TeamVee-Kanas/android_kernel_samsung_kanas,KristFoundation/Programs,KristFoundation/Programs,KristFoundation/Programs