for error-case kernel fault in sys_swapon
Subsystems (2)
PATCH 1/1 for error-case kernel fault in sys_swapon
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.
mm/swapfile.c renamed from mm/swapfile.c.0 +4 -2
@@ -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)) {