Ext2 oops fix in empty_dir()

Jan Kratochvil (short@k332.feld.cvut.cz)
Sun, 13 Apr 1997 11:03:26 +0200 (MET DST)


Hi!

I would normally send the following mail to Remi.Card@linux.org (official
maintainer of ext2 as listed in MAINTAINERS) but unfortunately this address
no longer exists. Can someone be so kind and update MAINTAINERS appropriately?

---------------------------------------------------------------------------

Hi!

I've made `rmdir' on a broken floppy (CRC errors) and got an ext2 oops...
The problem lies in `continue' statement which leaves `bh' NULL and iterates
next while. The modified if line dereferences NULL bh and we've got it.

Thanks for Linux hacking,
Jan Kratochvil

P.S.: The patch is made with 2.1.32 but namei.c is unmodified in 2.1.33 anyway.

--- linux/fs/ext2/namei.c-2.1.32 Sat Apr 12 14:07:52 1997
+++ linux/fs/ext2/namei.c Sat Apr 12 14:08:32 1997
@@ -583,7 +583,7 @@
offset = le16_to_cpu(de->rec_len) + le16_to_cpu(de1->rec_len);
de = (struct ext2_dir_entry *) ((char *) de1 + le16_to_cpu(de1->rec_len));
while (offset < inode->i_size ) {
- if ((void *) de >= (void *) (bh->b_data + sb->s_blocksize)) {
+ if (!bh || (void *) de >= (void *) (bh->b_data + sb->s_blocksize)) {
brelse (bh);
bh = ext2_bread (inode, offset >> EXT2_BLOCK_SIZE_BITS(sb), 1, &err);
if (!bh) {