coreboot/src/cpu/intel
Vladimir Serbinenko 2c88cc0696 Intel microcode: Return when microcode_updates is NULL
Add a safety check in function `intel_update_microcode` to return when
accidentally `NULL` is passed as `microcode_updates`, which would lead
to a null pointer dereference later on.

    for (c = microcode_updates; m->hdrver; m = (const struct microcode *)c) {

While at it, use `return NULL` for clarity in function
`intel_microcode_find` and include the header file `stddef.h`. for it.

The review of this patch had some more discussion on adding more
comments and more detailed error messages. But this should be done in
a separate patch.

For clarity here some history, on how this was found and what caused
the discussion and confusion.

Originally when Vladimir made this improvement, selecting
`CPU_MICROCODE_IN_CBFS` in Kconfig but not having the microcode blob
`cpu_microcode_blob.bin` in CBFS resulted in a null pointer dereference
later on causing a crash.

    for (c = microcode_updates; m->hdrver; m = (const struct microcode *)c) {

Vladimir fixed this by returning if `microcode_updates` is `NULL`,
that means no file is found and successfully tested this on his
Lenovo X201.

When pushing the patch to Gerrit for review, the code was rewritten
though by Aaron in commit »intel microcode: split up microcode loading
stages« (98ffb426) [1], which also returns when no file is found. So
the other parts of the code were checked and the safety check as
described above is added.

[1] http://review.coreboot.org/2778

Change-Id: I6e18fd37256910bf047061e4633a66cf29ad7b69
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Signed-off-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-on: http://review.coreboot.org/2990
Reviewed-by: Aaron Durbin <adurbin@google.com>
Tested-by: build bot (Jenkins)
2013-04-23 03:30:22 +02:00
..
car GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
ep80579 GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
fit x86 intel: Add Firmware Interface Table support 2013-03-17 22:53:51 +01:00
haswell haswell: enable ROM caching 2013-04-03 19:26:05 +02:00
hyperthreading Intel CPUs: Fix counting of CPU cores 2012-08-03 12:19:31 +02:00
microcode Intel microcode: Return when microcode_updates is NULL 2013-04-23 03:30:22 +02:00
model_6bx Get rid of drivers class 2012-11-27 22:00:49 +01:00
model_6dx Get rid of drivers class 2012-11-27 22:00:49 +01:00
model_6ex GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
model_6fx Intel: Update CPU microcode for 6fx CPUs 2013-03-21 23:20:40 +01:00
model_6xx Get rid of drivers class 2012-11-27 22:00:49 +01:00
model_65x GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
model_67x GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
model_68x GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
model_69x Get rid of drivers class 2012-11-27 22:00:49 +01:00
model_106cx Intel: Update CPU microcode for 106cx CPUs 2013-03-21 23:20:06 +01:00
model_206ax x86: Unify arch/io.h and arch/romcc_io.h 2013-03-22 00:00:09 +01:00
model_1067x Intel: Update CPU microcode for 1067x CPUs 2013-03-20 04:15:17 +01:00
model_f0x Get rid of drivers class 2012-11-27 22:00:49 +01:00
model_f1x Get rid of drivers class 2012-11-27 22:00:49 +01:00
model_f2x Get rid of drivers class 2012-11-27 22:00:49 +01:00
model_f3x Get rid of drivers class 2012-11-27 22:00:49 +01:00
model_f4x Get rid of drivers class 2012-11-27 22:00:49 +01:00
slot_1 GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
slot_2 GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
socket_441 GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
socket_BGA956 intel/socket_BGA956: enable speedstep, CAR, MMX, SSE 2012-11-06 21:51:43 +01:00
socket_FC_PGA370 GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
socket_LGA771 Remove chip.h files without config structure 2012-10-07 12:55:04 +02:00
socket_LGA775 Fix socket LGA775 2013-03-07 00:46:32 +01:00
socket_mFCBGA479 Remove chip.h files without config structure 2012-10-07 12:55:04 +02:00
socket_mFCPGA478 Remove chip.h files without config structure 2012-10-07 12:55:04 +02:00
socket_mPGA478 Remove chip.h files without config structure 2012-10-07 12:55:04 +02:00
socket_mPGA479M Remove chip.h files without config structure 2012-10-07 12:55:04 +02:00
socket_mPGA603 Fix typo in mPGA603 socket 2012-10-07 21:48:37 +02:00
socket_mPGA604 Remove chip.h files without config structure 2012-10-07 12:55:04 +02:00
socket_PGA370 GPLv2 notice: Unify all files to just use one space in »MA 02110-1301« 2013-03-01 10:16:08 +01:00
socket_rPGA989 Remove chip.h files without config structure 2012-10-07 12:55:04 +02:00
speedstep sconfig: rename lapic_cluster -> cpu_cluster 2013-02-14 07:07:20 +01:00
thermal_monitoring drop unused code (trivial) 2008-08-01 11:53:39 +00:00
turbo Add support for Intel Turbo Boost feature 2012-04-03 20:29:33 +02:00
Kconfig x86 intel: Add Firmware Interface Table support 2013-03-17 22:53:51 +01:00
Makefile.inc haswell: Add initial support for Haswell platforms 2013-03-14 01:44:40 +01:00