Commit 675d48b7 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] oops on HPFS filesystem file rename

Maurice van der Stee noted that he got an oops on a HPFS filesystem when
saving an edited file..

  <stares at the code>
  <blinks>
  <wonders whereTF do we assign hpfs1_i and hpfs2_i if both inodes are non-NULL>
  <finds the patch in question>
  <stares at jgarzik>

This fixes it.  That, BTW, means that *nobody* had ever tried to use
hpfs r/w since 2.5.3-pre3.
parent ea4a229c
...@@ -62,56 +62,28 @@ void hpfs_unlock_inode(struct inode *i) ...@@ -62,56 +62,28 @@ void hpfs_unlock_inode(struct inode *i)
void hpfs_lock_2inodes(struct inode *i1, struct inode *i2) void hpfs_lock_2inodes(struct inode *i1, struct inode *i2)
{ {
struct hpfs_inode_info *hpfs_i1 = NULL, *hpfs_i2 = NULL; if (!i2 || i1 == i2) {
hpfs_lock_inode(i1);
if (!i1) { } else if (!i1) {
if (i2) { hpfs_lock_inode(i2);
hpfs_i2 = hpfs_i(i2); } else {
down(&hpfs_i2->i_sem); struct hpfs_inode_info *hpfs_i1 = hpfs_i(i1);
} struct hpfs_inode_info *hpfs_i2 = hpfs_i(i2);
return;
}
if (!i2) {
if (i1) {
hpfs_i1 = hpfs_i(i1);
down(&hpfs_i1->i_sem);
}
return;
}
if (i1->i_ino < i2->i_ino) { if (i1->i_ino < i2->i_ino) {
down(&hpfs_i1->i_sem); down(&hpfs_i1->i_sem);
down(&hpfs_i2->i_sem); down(&hpfs_i2->i_sem);
} else if (i1->i_ino > i2->i_ino) { } else {
down(&hpfs_i2->i_sem); down(&hpfs_i2->i_sem);
down(&hpfs_i1->i_sem); down(&hpfs_i1->i_sem);
} else down(&hpfs_i1->i_sem); }
}
} }
void hpfs_unlock_2inodes(struct inode *i1, struct inode *i2) void hpfs_unlock_2inodes(struct inode *i1, struct inode *i2)
{ {
struct hpfs_inode_info *hpfs_i1 = NULL, *hpfs_i2 = NULL; /* order of up() doesn't matter here */
hpfs_unlock_inode(i1);
if (!i1) { hpfs_unlock_inode(i2);
if (i2) {
hpfs_i2 = hpfs_i(i2);
up(&hpfs_i2->i_sem);
}
return;
}
if (!i2) {
if (i1) {
hpfs_i1 = hpfs_i(i1);
up(&hpfs_i1->i_sem);
}
return;
}
if (i1->i_ino < i2->i_ino) {
up(&hpfs_i2->i_sem);
up(&hpfs_i1->i_sem);
} else if (i1->i_ino > i2->i_ino) {
up(&hpfs_i1->i_sem);
up(&hpfs_i2->i_sem);
} else up(&hpfs_i1->i_sem);
} }
void hpfs_lock_3inodes(struct inode *i1, struct inode *i2, struct inode *i3) void hpfs_lock_3inodes(struct inode *i1, struct inode *i2, struct inode *i3)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment