|
@@ -360,7 +360,7 @@ static size_t bzimage_load_initrd ( struct image *image,
|
360
|
360
|
char *filename = initrd->cmdline;
|
361
|
361
|
char *cmdline;
|
362
|
362
|
struct cpio_header cpio;
|
363
|
|
- size_t offset = 0;
|
|
363
|
+ size_t offset;
|
364
|
364
|
size_t name_len;
|
365
|
365
|
size_t pad_len;
|
366
|
366
|
|
|
@@ -368,7 +368,7 @@ static size_t bzimage_load_initrd ( struct image *image,
|
368
|
368
|
if ( initrd == image )
|
369
|
369
|
return 0;
|
370
|
370
|
|
371
|
|
- /* Create cpio header before non-prebuilt images */
|
|
371
|
+ /* Create cpio header for non-prebuilt images */
|
372
|
372
|
if ( filename && filename[0] ) {
|
373
|
373
|
cmdline = strchr ( filename, ' ' );
|
374
|
374
|
name_len = ( ( cmdline ? ( ( size_t ) ( cmdline - filename ) )
|
|
@@ -383,24 +383,20 @@ static size_t bzimage_load_initrd ( struct image *image,
|
383
|
383
|
bzimage_parse_cpio_cmdline ( image, &cpio,
|
384
|
384
|
( cmdline + 1 /* ' ' */ ));
|
385
|
385
|
}
|
386
|
|
- if ( address ) {
|
387
|
|
- copy_to_user ( address, offset, &cpio,
|
388
|
|
- sizeof ( cpio ) );
|
389
|
|
- }
|
390
|
|
- offset += sizeof ( cpio );
|
391
|
|
- if ( address ) {
|
392
|
|
- memset_user ( address, offset, 0, name_len );
|
393
|
|
- copy_to_user ( address, offset, filename,
|
394
|
|
- ( name_len - 1 /* NUL (or space) */ ) );
|
395
|
|
- }
|
396
|
|
- offset += name_len;
|
397
|
|
- offset = ( ( offset + 0x03 ) & ~0x03 );
|
|
386
|
+ offset = ( ( sizeof ( cpio ) + name_len + 0x03 ) & ~0x03 );
|
|
387
|
+ } else {
|
|
388
|
+ offset = 0;
|
398
|
389
|
}
|
399
|
390
|
|
400
|
|
- /* Copy in initrd image body */
|
401
|
|
- if ( address )
|
402
|
|
- memmove_user ( address, offset, initrd->data, 0, initrd->len );
|
|
391
|
+ /* Copy in initrd image body (and cpio header if applicable) */
|
403
|
392
|
if ( address ) {
|
|
393
|
+ memmove_user ( address, offset, initrd->data, 0, initrd->len );
|
|
394
|
+ if ( offset ) {
|
|
395
|
+ memset_user ( address, 0, 0, offset );
|
|
396
|
+ copy_to_user ( address, 0, &cpio, sizeof ( cpio ) );
|
|
397
|
+ copy_to_user ( address, sizeof ( cpio ), filename,
|
|
398
|
+ ( name_len - 1 /* NUL (or space) */ ) );
|
|
399
|
+ }
|
404
|
400
|
DBGC ( image, "bzImage %p initrd %p [%#08lx,%#08lx,%#08lx)"
|
405
|
401
|
"%s%s\n", image, initrd, user_to_phys ( address, 0 ),
|
406
|
402
|
user_to_phys ( address, offset ),
|