|
@@ -157,7 +157,7 @@ void comboot_force_text_mode ( void ) {
|
157
|
157
|
* Fetch kernel and optional initrd
|
158
|
158
|
*/
|
159
|
159
|
static int comboot_fetch_kernel ( char *kernel_file, char *cmdline ) {
|
160
|
|
- struct image *kernel;
|
|
160
|
+ struct image *kernel = NULL;
|
161
|
161
|
struct image *initrd = NULL;
|
162
|
162
|
char *initrd_file;
|
163
|
163
|
int rc;
|
|
@@ -181,13 +181,13 @@ static int comboot_fetch_kernel ( char *kernel_file, char *cmdline ) {
|
181
|
181
|
if ( ! initrd ) {
|
182
|
182
|
DBG ( "COMBOOT: could not allocate initrd\n" );
|
183
|
183
|
rc = -ENOMEM;
|
184
|
|
- goto err_alloc_initrd;
|
|
184
|
+ goto out;
|
185
|
185
|
}
|
186
|
186
|
if ( ( rc = imgfetch ( initrd, initrd_file,
|
187
|
187
|
register_image ) ) != 0 ) {
|
188
|
188
|
DBG ( "COMBOOT: could not fetch initrd: %s\n",
|
189
|
189
|
strerror ( rc ) );
|
190
|
|
- goto err_fetch_initrd;
|
|
190
|
+ goto out;
|
191
|
191
|
}
|
192
|
192
|
|
193
|
193
|
/* Restore space after initrd name, if applicable */
|
|
@@ -202,32 +202,31 @@ static int comboot_fetch_kernel ( char *kernel_file, char *cmdline ) {
|
202
|
202
|
if ( ! kernel ) {
|
203
|
203
|
DBG ( "COMBOOT: could not allocate kernel\n" );
|
204
|
204
|
rc = -ENOMEM;
|
205
|
|
- goto err_alloc_kernel;
|
|
205
|
+ goto out;
|
206
|
206
|
}
|
207
|
207
|
if ( ( rc = imgfetch ( kernel, kernel_file,
|
208
|
208
|
register_image ) ) != 0 ) {
|
209
|
209
|
DBG ( "COMBOOT: could not fetch kernel: %s\n",
|
210
|
210
|
strerror ( rc ) );
|
211
|
|
- goto err_fetch_kernel;
|
|
211
|
+ goto out;
|
212
|
212
|
}
|
213
|
213
|
if ( ( rc = image_set_cmdline ( kernel, cmdline ) ) != 0 ) {
|
214
|
214
|
DBG ( "COMBOOT: could not set kernel command line: %s\n",
|
215
|
215
|
strerror ( rc ) );
|
216
|
|
- goto err_set_cmdline;
|
|
216
|
+ goto out;
|
217
|
217
|
}
|
218
|
218
|
|
219
|
219
|
/* Store kernel as replacement image */
|
220
|
|
- comboot_replacement_image = kernel;
|
221
|
|
-
|
222
|
|
- return 0;
|
223
|
|
-
|
224
|
|
- err_set_cmdline:
|
225
|
|
- err_fetch_kernel:
|
|
220
|
+ assert ( comboot_replacement_image == NULL );
|
|
221
|
+ comboot_replacement_image = image_get ( kernel );
|
|
222
|
+
|
|
223
|
+ out:
|
|
224
|
+ /* Drop image references unconditionally; either we want to
|
|
225
|
+ * discard them, or they have been registered and we should
|
|
226
|
+ * drop out local reference.
|
|
227
|
+ */
|
226
|
228
|
image_put ( kernel );
|
227
|
|
- err_alloc_kernel:
|
228
|
|
- err_fetch_initrd:
|
229
|
229
|
image_put ( initrd );
|
230
|
|
- err_alloc_initrd:
|
231
|
230
|
return rc;
|
232
|
231
|
}
|
233
|
232
|
|