Skip to contentSkip to conversation

swapfile.c

PATCH In review [email protected] 4 participants 4 messages Mar 2, 2002 – Mar 4, 2002

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 swapfile.c

In 2.5.2 swapfile.c was broken:
In sys_swapon() we see

	swap_file = filp_open(name, O_RDWR, 0);
	if (IS_ERR(swap_file))
		goto bad_swap_2;

bad_swap_2:

	...
	if (swap_file)
		filp_close(swap_file, NULL);

and this oopses the kernel.
Below a trivial fix. Somebody with more time may come back and polish stuff a little.

Andries

swapfile.c renamed from swapfile.c~ +3 -1
@@ -905,8 +905,10 @@
 	swap_file = filp_open(name, O_RDWR, 0);
 	putname(name);
 	error = PTR_ERR(swap_file);
-	if (IS_ERR(swap_file))
+	if (IS_ERR(swap_file)) {
+		swap_file = NULL;
 		goto bad_swap_2;
+	}
 
 	p->swap_file = swap_file;
 

[this was a patch relative to 2.5.6-pre2]

#1 lore raw
Quoted 7 lines · On Сбт, Мар 02, 2002 at 09:25:16 +0000, [email protected] wrote:

In 2.5.2 swapfile.c was broken:
In sys_swapon() we see

	swap_file = filp_open(name, O_RDWR, 0);
	if (IS_ERR(swap_file))
		goto bad_swap_2;
Quoted 6 lines

bad_swap_2:

	...
	if (swap_file)
		filp_close(swap_file, NULL);

and this oopses the kernel.

Fixed in -dj tree.

Signature · 2 lines
Andrey Panin            | Embedded systems software engineer
[email protected]        | PGP key: wwwkeys.eu.pgp.net
#2 lore raw
Quoted 8 lines · Andrey Panin
Quoted 7 lines · On Сбт, Мар 02, 2002 at 09:25:16 +0000, [email protected] wrote:

In 2.5.2 swapfile.c was broken:
In sys_swapon() we see

	swap_file = filp_open(name, O_RDWR, 0);
	if (IS_ERR(swap_file))
		goto bad_swap_2;
Quoted 8 lines
Quoted 6 lines

bad_swap_2:

	...
	if (swap_file)
		filp_close(swap_file, NULL);

and this oopses the kernel.

Fixed in -dj tree.

Eww, nice spotting Andries. If it is in the -dj tree, someone want to push that bit to Linus?

Robert Love

#3 lore raw
In reply to [email protected]
Quoted 3 lines · Robert Love
Quoted 1 line

Fixed in -dj tree.

Eww, nice spotting Andries. If it is in the -dj tree, someone want to push that bit to Linus?

Actually, I only just applied that to my tree last night. Possibly Andrey was mixing it up to the IS_ERR fix that went in a while ago..

Signature · 2 lines
| Dave Jones.        http://www.codemonkey.org.uk
| SuSE Labs