[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140627163423.GG13337@redhat.com>
Date: Fri, 27 Jun 2014 12:34:23 -0400
From: Vivek Goyal <vgoyal@...hat.com>
To: linux-kernel@...r.kernel.org, kexec@...ts.infradead.org
Cc: ebiederm@...ssion.com, hpa@...or.com, mjg59@...f.ucam.org,
greg@...ah.com, bp@...en8.de, dyoung@...hat.com,
chaowang@...hat.com, bhe@...hat.com, akpm@...ux-foundation.org
Subject: [PATCH 16/15] kexec: Fix freeing up for image loader data loading
During testing I noticed a crash. Which in turn showed that there are
problems with how I am freeing up image->image_loader_data.
In one case I am freeing up kimage->image_loader_data first and then
calling up arch to free up which might have been contained in that
structure. That's wrong.
I have done little cleanup and this should fix the issues around
freeing up of loader data.
Signed-off-by: Vivek Goyal <vgoyal@...hat.com>
---
arch/x86/kernel/kexec-bzimage64.c | 4 ++--
arch/x86/kernel/machine_kexec_64.c | 2 +-
include/linux/kexec.h | 2 +-
kernel/kexec.c | 11 ++++++++---
4 files changed, 12 insertions(+), 7 deletions(-)
Index: linux-2.6/arch/x86/kernel/machine_kexec_64.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/machine_kexec_64.c 2014-06-27 09:55:41.824755401 -0400
+++ linux-2.6/arch/x86/kernel/machine_kexec_64.c 2014-06-27 11:02:02.607548946 -0400
@@ -369,7 +369,7 @@ int arch_kimage_file_post_load_cleanup(s
if (!image->fops || !image->fops->cleanup)
return 0;
- return image->fops->cleanup(image);
+ return image->fops->cleanup(image->image_loader_data);
}
/*
Index: linux-2.6/include/linux/kexec.h
===================================================================
--- linux-2.6.orig/include/linux/kexec.h 2014-06-27 09:55:41.695754029 -0400
+++ linux-2.6/include/linux/kexec.h 2014-06-27 11:04:28.467151813 -0400
@@ -190,7 +190,7 @@ typedef void *(kexec_load_t)(struct kima
unsigned long kernel_len, char *initrd,
unsigned long initrd_len, char *cmdline,
unsigned long cmdline_len);
-typedef int (kexec_cleanup_t)(struct kimage *image);
+typedef int (kexec_cleanup_t)(void *loader_data);
struct kexec_file_ops {
kexec_probe_t *probe;
Index: linux-2.6/arch/x86/kernel/kexec-bzimage64.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/kexec-bzimage64.c 2014-06-27 09:55:41.872755912 -0400
+++ linux-2.6/arch/x86/kernel/kexec-bzimage64.c 2014-06-27 11:05:42.151963710 -0400
@@ -512,9 +512,9 @@ out_free_params:
}
/* This cleanup function is called after various segments have been loaded */
-int bzImage64_cleanup(struct kimage *image)
+int bzImage64_cleanup(void *loader_data)
{
- struct bzimage64_data *ldata = image->image_loader_data;
+ struct bzimage64_data *ldata = loader_data;
if (!ldata)
return 0;
Index: linux-2.6/kernel/kexec.c
===================================================================
--- linux-2.6.orig/kernel/kexec.c 2014-06-27 10:04:23.409024171 -0400
+++ linux-2.6/kernel/kexec.c 2014-06-27 11:45:14.684874978 -0400
@@ -459,6 +459,14 @@ static void kimage_file_post_load_cleanu
/* See if architecture has anything to cleanup post load */
arch_kimage_file_post_load_cleanup(image);
+
+ /*
+ * Above call should have called into bootloader to free up
+ * any data stored in kimage->image_loader_data. It should
+ * be ok now to free it up.
+ */
+ kfree(image->image_loader_data);
+ image->image_loader_data = NULL;
}
/*
@@ -584,7 +592,6 @@ out_free_control_pages:
kimage_free_page_list(&image->control_pages);
out_free_post_load_bufs:
kimage_file_post_load_cleanup(image);
- kfree(image->image_loader_data);
out_free_image:
kfree(image);
return ret;
@@ -908,8 +915,6 @@ static void kimage_free(struct kimage *i
/* Free the kexec control pages... */
kimage_free_page_list(&image->control_pages);
- kfree(image->image_loader_data);
-
/*
* Free up any temporary buffers allocated. This might hit if
* error occurred much later after buffer allocation.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists