[PATCH] for error-case kernel fault in sys_swapon

From: Jan Beulich
Date: Mon Mar 15 2004 - 06:56:20 EST


In the epilogue code, 'name' was passed to putname() regardless of
whether getname() succeeded, whereas 'swap_file' was cleared to NULL and
nevertheless checked through IS_ERR(). The patch fixes the first and
streamlines the second.

Jan Beulich
Novell, Inc.

--- 2.6.3/mm/swapfile.c.0 2004-03-02 16:35:17.000000000 +0100
+++ 2.6.3/mm/swapfile.c 2004-03-15 12:46:12.597498944 +0100
@@ -1269,8 +1269,10 @@
swap_list_unlock();
name = getname(specialfile);
error = PTR_ERR(name);
- if (IS_ERR(name))
+ if (IS_ERR(name)) {
+ name = NULL;
goto bad_swap_2;
+ }
swap_file = filp_open(name, O_RDWR, 0);
error = PTR_ERR(swap_file);
if (IS_ERR(swap_file)) {
@@ -1456,7 +1458,7 @@
destroy_swap_extents(p);
if (swap_map)
vfree(swap_map);
- if (swap_file && !IS_ERR(swap_file))
+ if (swap_file)
filp_close(swap_file, NULL);
out:
if (page && !IS_ERR(page)) {

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/