@@ -373,12 +373,20 @@ static inline void smp_prepare_cpus(unsigned int maxcpus) { }
373
373
*/
374
374
static void __init setup_command_line (char * command_line )
375
375
{
376
- saved_command_line =
377
- memblock_alloc (strlen (boot_command_line ) + 1 , SMP_CACHE_BYTES );
378
- initcall_command_line =
379
- memblock_alloc (strlen (boot_command_line ) + 1 , SMP_CACHE_BYTES );
380
- static_command_line = memblock_alloc (strlen (command_line ) + 1 ,
381
- SMP_CACHE_BYTES );
376
+ size_t len = strlen (boot_command_line ) + 1 ;
377
+
378
+ saved_command_line = memblock_alloc (len , SMP_CACHE_BYTES );
379
+ if (!saved_command_line )
380
+ panic ("%s: Failed to allocate %zu bytes\n" , __func__ , len );
381
+
382
+ initcall_command_line = memblock_alloc (len , SMP_CACHE_BYTES );
383
+ if (!initcall_command_line )
384
+ panic ("%s: Failed to allocate %zu bytes\n" , __func__ , len );
385
+
386
+ static_command_line = memblock_alloc (len , SMP_CACHE_BYTES );
387
+ if (!static_command_line )
388
+ panic ("%s: Failed to allocate %zu bytes\n" , __func__ , len );
389
+
382
390
strcpy (saved_command_line , boot_command_line );
383
391
strcpy (static_command_line , command_line );
384
392
}
@@ -770,8 +778,14 @@ static int __init initcall_blacklist(char *str)
770
778
pr_debug ("blacklisting initcall %s\n" , str_entry );
771
779
entry = memblock_alloc (sizeof (* entry ),
772
780
SMP_CACHE_BYTES );
781
+ if (!entry )
782
+ panic ("%s: Failed to allocate %zu bytes\n" ,
783
+ __func__ , sizeof (* entry ));
773
784
entry -> buf = memblock_alloc (strlen (str_entry ) + 1 ,
774
785
SMP_CACHE_BYTES );
786
+ if (!entry -> buf )
787
+ panic ("%s: Failed to allocate %zu bytes\n" ,
788
+ __func__ , strlen (str_entry ) + 1 );
775
789
strcpy (entry -> buf , str_entry );
776
790
list_add (& entry -> next , & blacklisted_initcalls );
777
791
}
0 commit comments