2002-03-02 21:25:43

by Andries E. Brouwer

[permalink] [raw]
Subject: [PATCH] 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~ Sat Mar 2 18:23:19 2002
+++ swapfile.c Sun Mar 3 23:08:48 2002
@@ -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]


2002-03-04 11:24:34

by Andrey Panin

[permalink] [raw]
Subject: Re: [PATCH] swapfile.c

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;
>
> bad_swap_2:
> ...
> if (swap_file)
> filp_close(swap_file, NULL);
>
> and this oopses the kernel.

Fixed in -dj tree.

--
Andrey Panin | Embedded systems software engineer
[email protected] | PGP key: wwwkeys.eu.pgp.net


Attachments:
(No filename) (475.00 B)
(No filename) (232.00 B)
Download all attachments

2002-03-04 18:48:47

by Robert Love

[permalink] [raw]
Subject: Re: [PATCH] swapfile.c

On Mon, 2002-03-04 at 06:28, Andrey Panin wrote:
> 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;
> >
> > 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

2002-03-04 19:15:10

by Dave Jones

[permalink] [raw]
Subject: Re: [PATCH] swapfile.c

On Mon, Mar 04, 2002 at 01:48:08PM -0500, Robert Love wrote:
> > 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..

--
| Dave Jones. http://www.codemonkey.org.uk
| SuSE Labs